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

1 Answer 1


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. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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