php 显示每个分类术语存档页面中的所有帖子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 显示每个分类术语存档页面中的所有帖子相关的知识,希望对你有一定的参考价值。

<?php
$term = get_queried_object();
$args = array(
    'post_type' => 'products',
    'product-categories' => $term->slug
);
$query = new WP_Query( $args );
	echo $term->name;
if ($query->have_posts()) {
         
    // output the term name in a heading tag                
    echo'<h2>Animals in the ' . $term->name . ' Family</h2>';
     
    // output the post titles in a list
    echo '<ul>';
     
        // Start the Loop
        while ( $query->have_posts() ) : $query->the_post(); ?>
 
        <li class="animal-listing" id="post-<?php the_ID(); ?>">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </li>
         
        <?php endwhile;
         
        echo '</ul>';
         
}
wp_reset_postdata();
?>

以上是关于php 显示每个分类术语存档页面中的所有帖子的主要内容,如果未能解决你的问题,请参考以下文章