I've got a strange problem. I'm programming a custom post archive page. I'm using wp conventions, so I've got a 'project' custom post type and an archive-project.php page, which is correctly showing project posts.

The problem is that currently I've got far more than 10 posts, but the page will always chow max 10 posts, despite of admin settings or wo_query modifications. If I set less than 10 posts, they will be correctly showed. If I set more than 10 (from admin) OR if I disable the paging via code, they will be always no more than 10.

Even more strange: I checked the generated query, and if I disable paging, it correctly doesn't contain any LIMIT constrain. Still, returned posts are 10.

Now, what I really want is simply the page to show ALL the posts, so, no paging. I've tried several ways (I'm a programmer, I know wordpress) such this (and others along):

function set_projects_query($query) {
  if(is_admin() || !$query->is_main_query()) return $query; //do nothing

    // $query->set('posts_per_page', -1); < this first
    // $query->set('posts_per_archive_page', -1); < then this
    $query->set('nopaging', true); // < then this


Again, what I get is a correct query: $wp_query->request will show a query without any LIMIT, though, 10 posts and no more.

Why? Any idea?


Ok, found the issue. By analizing the generated query, I realized that it rightly searched for current language posts. I'm currently use polylang as the multilingual plugin, and it correctly associate posts with a 'language' taxonomy.

Now, I had far more 10 project posts but only 10 where of the current language.

All fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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