I know that there are a lot of topics on this question and I've read a lot of them and tried different things. But pagination is still not working. I think it has something to do with the permalink settings.

The situation

I have a custom post type called artists which I link to events. On the artist page I show all the events the artist is linked to (they're linked using the posts 2 posts plugin). I'd like to paginate these events. Let's use ACDC as an example artist.

The pagination is showing, and the links point to root/artist/acdc/page/# where # is the page number.

If I click on page 2 for example I'm not going to root/artists/acdc/page/2. The page does seem to load, but I end up at the same URL showing the first 3 posts (roots/artists/acdc). So I don't get a 404.

When I go to root/artists/acdc?page=2, the URL becomes root/artists/acdc/2/, but it still displays the 3 posts from page 1. This happens when 'format' is set to '/page/%#%' in paginate_links. If I then hover the pagination link for page 3, the link becomes root/artists/acdc/2/page/3...

My settings

  • Permalink custom structure: /%category%/%postname%/
  • I'm using the roots theme which does apply some rewrites, but I as far as I can see there are not rewrites for the permalinks / page structure

Stuf I've already tried

  • Changed 'show maximum of' setting in WP settings from 10 to 1
  • Changed 'paged' to 'page' in $paged
  • Going to the URL root/artists/acdc/page/2, no luck as described above
  • Going to the URL root/artists/acdc?page=2, no luck and weird behavior as described above
  • Changed 'format' in paginate_links to '?page=%#%'

My code (which is on the artist custom post type template but will eventually be stored in functions.php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args = array(
    'connected_type' => 'artists_to_events',
    'connected_items' => get_queried_object(),
    'post_type' => 'events',
    'post_status' => 'publish',
    'posts_per_page' => 3,
    'paged' => $paged,
    'meta_key' => 'custom_date',
    'orderby'=> 'meta_value',
    'order' => 'ASC'

$query = new WP_Query($args);

$big = 99999999;

echo paginate_links(array(
    'base' => str_replace($big, '%#%', get_pagenum_link($big)),
    'format' => '/page/%#%',
    'total' => $query->max_num_pages,
    'current' => max(1, get_query_var('paged')),
    'show_all' => false,
    'end_size' => 2,
    'mid_size' => 3,
    'prev_next' => true,
    'prev_text' => 'Vorige',
    'next_text' => 'Volgende',
    'type' => 'list'

Because of the weird URL behaviour I don't really know where the problem lies. Any ideas?

1 Answer 1


I've found the problem. Since I'm on a single (custom) post page, WP redirects back to the root of the URL. I've found the solution here.

The solution (copied from the post on SO) was adding this to the functions.php:


function pif_disable_redirect_canonical($redirect_url) {
if( is_singular()) {
    $redirect_url = false;
return $redirect_url;

I've removed && in_category('PLACE CAT ID HERE') from the original code in the post to tailor to my situation.

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.