自定义分类术语与特定帖子相关联

时间:2018-06-04 14:44:06

标签: php wordpress custom-taxonomy

我需要在自定义分类中显示一组与特定帖子相关联的术语,我尝试了大量的方法而没有运气。

我对PHP游戏有点新鲜,所以非常感谢任何帮助。这是我目前的代码:

<?php $args = array (
'post_type' => 'artwork',
'meta_query' => array(
'relation' => 'OR',
array(
    'key'     => 'featured',
    'value'   => 'feature',
    'compare' => 'LIKE',
)
));
            $the_query = new WP_Query($args);
            ?>
<?php $i = 1; ?>
            <?php  if ($the_query->have_posts() ): while ($the_query- 
>have_posts() && $i < 2) :$the_query->the_post(); ?>

    <a href="<?php the_permalink(); ?>">
    <div class="top_featured" style="background-image: url('<?php 
the_post_thumbnail_url(); ?>')">
            <div class="item_meta">
                <?php
$creator = get_field('creator');?>
            <h2><?php the_title(); ?></h2>
            <p>By <?php echo $creator; ?></p>

<p class="art_genre"><a href="TAXONOMY TERM LINK HERE">TAXONOMY TERM 
NAME HERE</a></p>

            </div>


        <div class="item_featured">
            <img src="/wp-content/uploads/2018/06/featured_star.png">
        <p>Featured</p>
        </div>



    </div>
    </a> 
            <?php $i++; endwhile; ?>
            <?php endif; ?>

0 个答案:

没有答案