WordPress archive pages show a limited number of items, controlled from the
Settings > Reading > Blog pages show at most section. The default is 10, and it applies to all archives, including Custom Post Types.
If you want to leave your posts page at 10 but show all of your portfolio pieces, what can you do? Well you could code up a new template and create your own fresh query. But you’d be doing it WRONG!
pre_get_posts action to the rescue!
pre_get_posts is a filter that allows us to modify an existing
WP_Query, before that query is actually run. This means we can filter for the number of posts to show.
Here’s a gist to show all posts in the Portfolio CPT archive page. Place this code in your
functions.php file, or your functionality plugin:
This is how we do it here on Spigot. Notice that our work page shows all the work we’ve published, without the annoyance of pagination!