• Resolved udidol

    (@udidol)


    Hi,
    a website I’m working on (which is still on a temporary domain) has a custom post type (“chapters”).

    The pagination in the custom post type archive page (http://udidollb.de2.fcomet.com/chapters/) doesn’t work – if you click the “2” pagination link (to go to page 2), it loads the URL http://udidollb.de2.fcomet.com/chapters/page/2/, but the contents are identical to page 1.

    I use a custom template file – archive-chapters.php, but the pagination function is the same as in the regular archive page – oceanwp_blog_pagination();.

    Any idea why the pagination doesn’t work?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author oceanwp

    (@oceanwp)

    Hello, you have created an archive page so you use a custom query, right?
    Add this code into the functions.php file of your child theme: https://pastebin.com/JbUbDfHY
    Then in your file, replace “oceanwp_blog_pagination();” by “my_cpt_pagination( $oceanwp_query->max_num_pages );”.
    Careful, you will need to replace the query variable by your variable name, for example, if your custom query variable is “$query”, you need to add this function “my_cpt_pagination( $query->max_num_pages );”.
    Tell me if it works.

    Thread Starter udidol

    (@udidol)

    Hey,
    Thank you for your quick response!
    I looked over your code and it made me realize that in my custom query’s argument list, I forgot to add 'paged' => (get_query_var('paged')). Once I added that, it worked perfectly.

    Sorry for the trouble and thanks again for your help!

    Theme Author oceanwp

    (@oceanwp)

    Glad that you found the solution to your issue 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Pagination doesn’t work for CPT’ is closed to new replies.