I need to set the post_per_page to display only 1 post here’s the code I use:
<?php
$yell = new WP_Query(array('posts_per_page' => 1,'post_type' => 'items', 'portfolio-category' => 'accessories'));
while ($yell->have_posts()) : $yell->the_post();
?>
<h2><?php the_title(); ?></h2>
<?php endwhile; wp_reset_query(); ?>
But it doesn’t show 1 post, it shows all. not sure why
You can do it with the post_limits filter:
Update: If you only want this to run for your custom query, you could do the following:
Code would be like so: