• Resolved olistic

    (@olistic)


    Hi,

    There’s a page of my website where pagination doesn’t work, while it works on all the other “normal” posts (i.e. /yogi-bhajan/).

    I’d like to add the pagination to that page (where all the post – 32 – of a single category are shown). This page takes the instructions from the pagina-libri.php file (https://pastebin.com/J2drHDDE), but I can’t figure out where I have to insert the suggested strings (i.e. from https://www.wpexplorer.com/pagination-wordpress-theme/).

    Could you please help me?

    Thank you in advance for every advice!

    • This topic was modified 2 years, 7 months ago by Jan Dembowski.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    The paginate_links() code needs to be inserted just before wp_reset_query(); but after endwhile;

    The pastebin code is forcing the global $wp_query object to do double duty. Once to get the page, then again to list posts in a category. In theory it should be workable, but there is potential for cross-talk of data between the two usages. I usually prefer to keep the secondary query (posts in a category) independent from global $wp_query by instantiating a custom query object for the purpose. Then get paginate_links() to use this custom query object instead of $wp_query.

    The catch is you’d then need to implement your own pagination query var, you cannot use ‘paged’ because that relates to the main page query. But ‘paged’ is often where the undesired cross-talk occurs, so it’s best to be divorced from that query var anyway. In fact, you can likely continue to use the global $wp_query object’s double duty if you were to get away from ‘paged’ and use your own pagination query var.

    Thread Starter olistic

    (@olistic)

    First of all, thank you @bcworkz for your reply.

    I’ve tried to insert the code just before wp_reset-query(); and after endhwile;, but the pagination was vertical (how strange!)… something as…
    1
    2
    3
    Next

    Anyway your instruction has been decisive, as I applied it using a plugin (Pagination) and inserting its code in my template-page, just before wp_reset-query(); and after endhwile;.

    Thank you very much!

    Moderator bcworkz

    (@bcworkz)

    The links being vertical stacked is just a CSS issue. Use your browser’s element inspector tool to help you figure out the right CSS. As a guess, each link container needs a float: left; rule and maybe a width: specification. Place whatever rules you decide you need in the Additional CSS customizer section.

    Thread Starter olistic

    (@olistic)

    Thank you for this other explanation.

    Thread Starter olistic

    (@olistic)

    Excuse me @bcworkz if I add now another question, but by chance I’ve found another issue linked to the main one.

    I’ve noticed than the tag-pages (i.e. yogajap.com/tag/umanologia/) shows me two paginations string (while on all the other pages where pagination works everything works fine – i.e. yogajap.com/blog/) :-\

    The first pagination is the one I’ve set using a plugin, but how can I find where the second string come from?

    Thank you in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding pagination’ is closed to new replies.