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

I don't get whats happening here.

I'm on a child-page template, generating a WP_Query for Custom Post Types on the fly, like this:

$notrel = new WP_Query(array(
    'post_type' => $type,
    'posts_per_page' => $perpage,
    'monthnum' => $mes,
    'year' => $ano,
    'paged' => $paged

Loops and $_GET filters for post_type, monthnum and yearare all working perfectly. But pagination is giving me trouble.

A) If i try the URL http://example.com/parent-page/child-page/page/4/ i get paged = 1.

B) On the other hand, http://example.com/parent-page/child-page/4/ correctly gives paged = 4 but pagination doesn't work since next_posts_link automatically shapes URLs like A.

I guess /page/4/ is standard, so why is it not working here? Is it maybe the rewrite parameter on register_post_type?

EDIT: still not solved, se this -> paginate_links() adds empty href to first page and previous link

share|improve this question
up vote 0 down vote accepted

I didn't really solve it, but got around with the help of Passing custom args in paginate_links and Custom paging function.

Initially I even thought of writing a patch to next_posts_link, but as it turns out, the URL formatting problem lies way below in the function soup, and that is really a downer when all I wanted was to reuse some earlier code that went into this template when it was still static.

My solution for now was to leave it all behind and start fresh with paginate_links(). Turns out that paginate_links doesn't care about permalink structure and always appends ?page=4 to the URL which just makes a lot more sense. :)

UPDATE: Followinfg along, I got this problem -> paginate_links() adds empty href to first page and previous link which was properly solved after all. :)

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.