Friday Next is no longer taking new clients or performing work for existing clients.

If you’re trying to query your posts, whether they are custom post types or just regular posts, you might have noticed that only 10 posts are showing up in your front end output.  There is a simple fix to this problem.

Posts per page

If you’re setting lots of arguments like ‘post_type’, ‘category’, etc, you might have forgotten one specific argument.  When you don’t set the ‘posts_per_page’ value, it will default to 10 ‘posts per page’.  This means that only 10 results will show up on your front end posts page.  You can set this number to the exact number of posts you want, or you can use a little trick to make sure it shows all the posts.

	$args = array(
		'posts_per_page' =&gt; -1,
	$query = query_posts( $args );

As you can see here, I’ve set the ‘posts_per_page’ value to ‘-1’. This allows the query to show all the matching posts, with no limit. It’s useful when you don’t mind having all of your results on one page, rather than having nicely paginated results.

Share This

Share this post with your friends!