按职位的子类别划分职位

时间:2019-05-24 10:41:14

标签: php wordpress categories taxonomy

在自定义帖子类型的分类页面中,我想按以下子类别将帖子划分:

H2:儿童类别1

文章列表

H2:儿童类别2

文章列表

H2:儿童类别3

文章列表

我可以使用带有类别的查询来手动执行此操作,但是由于以后可能会添加类别,因此,如果我们可以采用更灵活的(如cms)解决方案,这将是合适的。 这是我的代码,它打印出一个普通列表,其中所有帖子均未按类别划分。我该怎么办?

<ul class="menenlis">
        <?php
            if (have_posts()): while (have_posts()): the_post();
            $locations = get_the_terms($post->ID, 'menucat');
            $location = $locations[0]->name;
            $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'gallery-thumb');
            if(empty($thumbnail)) $thumbnail = APP_URL . "images/common/no-image.jpg";
        ?>
        <li>
            <a href="">
                <div class="imager" style="background-image: url(<?php echo $thumbnail; ?>);"></div>
                <div class="text">
                    <h3 class="name"><?php the_title(); ?></h3>
                    <p class="read">/read/</p>
                    <p class="price">/price/</p>
                    <p class="caption-b">/caption-b/</p>
                </div>
            </a>
        </li>
    <?php endwhile; endif;?>
</ul>

0 个答案:

没有答案