WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Many people report problems with pagination of custom queries or custom post type archives: url/page/2 produces a 404 even though all the setup is correct.

Many end up figuring out that this is occurring because the posts_per_page of their custom loop is less than the maximum posts per page setting in the admin, which they fix by changing

 Settings » Reading » "Blog pages show at most: ____ posts" 

to 1.

This works in my situation, but I would much prefer to change this only for this specific custom query, rather than the whole site. Is this possible?

The relevant WP_Query is this:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query( array(
'post_type' => 'publication',
'posts_per_page' => 5,
share|improve this question

I assume you have a custom post type: publication

in functions.php place that code:

function mk_parse_query($query) {
  if ($query->query_vars['post_type'] == 'publication')) {
        set_query_var( 'posts_per_page', 5 );
if( !is_admin() ) {

Similar code works for me, but in my case I was struggling with 404 on custom taxonomies paged urls.

Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.