Pagination for custom query on single.php

I’m building a site and the basic structure on most pages is as follows:

<!-- content query -->
<!-- recent posts preview query (paginated) -->
<!-- related posts preview query (paginated) -->

The paginated content is loading on the same page using jQuery, so just that specific section updates when the user navigates to the next page or a section.

Read More

Most of my pages are literally pages with custom templates on which I run custom queries (WP_query) for each thing. This works really well on the custom pages, but I am trying to implement it similarly on single.php. The structure I want on single.php is:

<!-- post content -->
<!-- recent posts preview query (paginated) -->
<!-- related posts preview query (paginated) -->

However, my code that works perfectly fine on custom pages has broken pagination on single.php. Researching this, it seems it may be conflicting with the fact that posts themselves can be paginated. I’ve not been able to find much more info than that.

Does anyone know if it’s possible to achieve my goal here?
Is there any workaround, in any capacity that would make it happen?

Thank you very much for any insight you might be able to offer!

Related posts

Leave a Reply

1 comment

  1. Well, for anyone else looking to solve a similar problem, I found this post, and it led me in the right direction: http://wordpress.org/support/topic/pagination-on-singlephp-causing-301-redirect?replies=9.

    I added this snippet of code to my functions.php, and I can paginate in custom queries without issue on single.php now. I don’t know enough about it to know what it does, but it seems to fix the problem!

    add_filter('redirect_canonical','pif_disable_redirect_canonical');
    
    function pif_disable_redirect_canonical($redirect_url) {
        if (is_singular('pov_channel')) $redirect_url = false;
    return $redirect_url;
    }