posts_per_page not work by term

I’m trying to limit the posts, but it does not work, it shows them all does not work ‘posts_per_page’ why?

<?php // Output all Taxonomies names with their respective items
$terms = get_terms(‘genres’);
foreach( $terms as $term ):
?>
<h3><?php echo $term->name; // Print the term name ?></h3>
<ul>
<?php
$posts = get_posts(array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 1,
‘taxonomy’ => $term->taxonomy,
‘term’ => $term->slug,
));
foreach($posts as $post): // begin cycle through posts of this taxonmy
setup_postdata($post); //set up post data for use in the loop (enables the_title(), etc without specifying a post ID)
?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

Read more here:: posts_per_page not work by term

Leave a Reply

Your email address will not be published. Required fields are marked *