Is it possible to remove the posts_per_page limit on a specific post type?

You can hook into the pre_get_posts action, to access the $query object.

You should use your action hook inside your functions.php.
An example of what your function could look like:

add_action( 'pre_get_posts', 'publications_archive_query' );
function publications_archive_query( $query ) {
  if ( !is_admin() && $query->is_main_query()) {
    if ( $query->get('post_type') === 'publications' ) {
      $query->set( 'posts_per_page', 5 );
    }
}

Narrow down what is the query you are modifying by using conditional checks.

$query->get('post_type') to get current’s Query post_type to check against.

is_main_query to make sure you are only applying your query modification to the main query.

Read further and find more examples:
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

Leave a Comment