如何显示相关类别,而不是显示相关标记的后续操作。如果您有任何帮助,我们将不胜感激。提前感谢
if(!function_exists(\'solstice_related_post\')) {
function solstice_related_post() {
global $post;
$tags = wp_get_post_tags($post->ID);
if(!empty($tags) && is_array($tags)):
$simlar_tag = $tags[0]->term_id;
?>
<div class="related-posts">
<h6><?php esc_html_e(\'YOU MIGHT ALSO LIKE\', \'solstice-theme\'); ?></h6>
<div class="row">
<?php
$args = array(
\'tag__in\' => array($simlar_tag),
\'post__not_in\' => array($post->ID),
\'posts_per_page\' => 3,
\'meta_query\' => array(array(\'key\' => \'_thumbnail_id\', \'compare\' => \'EXISTS\')),
\'ignore_sticky_posts\' => 1,
);
$re_query = new WP_Query($args);
while ($re_query->have_posts()) : $re_query->the_post();
?>
<article <?php post_class(\'blog-post col-md-4\'); ?>>
<header>
<figure>
<?php the_post_thumbnail(\'solstice-small\'); ?>
</figure>
<h3><a href="<?php echo esc_url(get_the_permalink()); ?>"><?php the_title(); ?></a></h3>
<div class="meta">
<span><?php echo get_the_category_list( \' , \', \'solstice-theme\' );?></span>
<span><time datetime="<?php the_time(\'Y-m-d\'); ?>"><?php the_time(\'F d, Y\'); ?></time></span>
</div><!-- /meta -->
</header>
</article>
<?php endwhile; wp_reset_postdata(); ?>
</div><!-- /row -->
</div><!-- /related-posts -->
<?php
endif;
}
}