最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom post types - How do I create an archive page as a <table> including metadata?

programmeradmin4浏览0评论

I'm really struggling getting this seemingly simple thing to work. I have a list of "vendors" as a CPT. They have metadata like "contact name" and "last invoice date". I'd like to have the "archive" page for these vendors show a simple table:

Name Contact name Last Invoice
Joe's Plumbing Joe Anderson March 31, 2021

I can not seem to figure out how to get metadata into this. I'm also struggling with getting Wordpress to stop inserting <h2>s, but at least I can style around that!

<!-- wp:template-part {"slug":"header", "tagName":"header"} /-->

<section class="wp-block-query inner-width content">
    <table>
    <!-- wp:query {"query":{"perPage":1000,"pages":0,"offset":0,"postType":"vendor","categoryIds":[],"tagIds":[],"order":"asc","orderBy":"title","author":"","search":"","exclude":[],"sticky":"","inherit":true},"tagName":"main","align":"wide","layout":{"inherit":false}} -->
        
        <!-- wp:post-template {"align":"wide"} -->
        <tr>
            <td><!-- wp:post-title {"isLink":true} /--></td>
            <td>Contact</td>
            <td>Last Invoice Date</td>
        </tr>
        <!-- /wp:post-template -->
    <!-- /wp:query -->
    </table>
</section>

<!-- wp:template-part {"slug":"footer", "tagName":"footer"} /-→

How can I make <td>Contact</td> the actual contact's name (meta data name contact)? I've seen other solutions using PHP, but when I do that on the HTML page it doesn't work. Maybe I followed the wrong guide?

发布评论

评论列表(0)

  1. 暂无评论