WordPress show all posts on a Custom Post Type archive page

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!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Check out our Complete Website Package

Chat with us about your project or click below to find out more!

Learn More   Chat with us

Hi. We are Spigot. Telemarketers pronounce it Spy-got.

We are a Park City, Utah based web design shop that excels at building custom websites powered by WordPress and WooCommerce. We love content - content strategy, content curation, content soup...????Have a look around the site. As you browse you'll find useful navigation links in the sidebar on the left. We hope you find them useful anyway... Please let us know what you think, shoot us a message here.