I know it's a common problem, but I tried every solution appeared on this stackexchange.

Every solution has failed (maybe because I'm still a newbie).

I've this query on index.php page:

if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }
query_posts('cat=4,8,12&posts_per_page=5&paged=' . $paged);
if (have_posts()) : ?><?php while(have_posts() ) : the_post() ; ?>

I've enabled permalinks and I'm also using a (famous) SEO plugin.

My articles page URL is: http://www.mysite.com/news/page/x where x is the number of the pagination.

Everything is working fine for the first 24 "pages", but from the 25th page the title become "Page not Found" and in breadcrumbs I can see "404".

The weird thing is that articles are still shown correctly with the correct pagination.

Any suggestion?

  • Any specific reason why you are using a custom query? Use pre_get_posts to properly modify the query variables before the main query executes Nov 19, 2014 at 15:55

1 Answer 1


Using query_posts is generally not recommended. Looking at the Codex, it specifically states:

Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use of pre_get_posts hook, for this purpose.

Note the "especially often when dealing with posts pagination" part.

I would try re-writing your code with one of the other suggested methods and see if that changes the behavior.

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.