代码之前需要WP\\U查询:
<?php
$allCat = array(
\'posts_per_page\' => 3,
\'tax_query\' => array(
array(
\'taxonomy\' => \'category-products\',
\'field\' => \'slug\',
\'terms\' => \'your-slug\',
)
)
);
?>
<?php $all_product = new WP_Query($allCat); ?>
<?php if($all_product -> have_posts()) : ?>
<?php while($all_product -> have_posts()) :
$all_product -> the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php endif; ?>