• Resolved TheMadWiddler1200

    (@themadwiddler1200)


    I would like to change the post lists pagination on my homepage to numbered pagination. I currently have it set to only have a “Newer Pages” and “Older Pages” buttons. But I would like for it to be numbered. Like have something like this “1 2 3 4 5 6 …… 50” Would I have to download a plugin to achieve this?

    Thanks in advance for your help!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter TheMadWiddler1200

    (@themadwiddler1200)

    Hi, d4z_c0nf

    Thank you for replying.

    The plugin you suggested works great! My post list nav now has numbered navigation. But the single post navigation is now gone. It use to have a “Next” and “Previous” buttons at the bottom of the posts, but now they’re gone. Is there a way I can add them back?

    Thank you for your help!

    add_action('wp_head', 'my_post_nav');
    function my_post_nav(){
        if ( ! function_exists('wp_pagenavi') || is_singular() )
            return;
        remove_action( '__after_loop' , array( TC_post_navigation::$instance , 'tc_post_nav' ), 20 );
        add_action( '__after_loop', 'wp_pagenavi', 20 );
    }

    should do the trick for all post lists, or do you want it just in home?

    Thread Starter TheMadWiddler1200

    (@themadwiddler1200)

    Thanks for your reply.

    I would like to have numbered navigation on the home page for the post lists and have “Next” and “Previous” buttons on single posts. I used to have navigation on my single post but it only had a “Next” and “Previous” buttons to navigate the single posts, but when I added the plugin you suggested they disappeared. I would like to keep those buttons in the single posts navigation. ??

    Do I have to replace the last snippet I added from the thread you linked to with this new one or do I just add it on a new line?

    Thanks for your help!

    Replace ??

    Thread Starter TheMadWiddler1200

    (@themadwiddler1200)

    You always come through, d4z_c0nf, always!! Thank you very much! Have a good one! ??

    You’re welcome Mad ??

    Great way instead default plugin instruction!
    d4z_c0nf, thank you very much!

    But this snippet works well only in loop (on main page or in list of taxonomy).
    When post have a lot of comments than numbered pagination on post page doesn’t works. In this case we have 2 leveles of pagination: comments and posts. And both of them have default text pagination. Could you help?

    Regards,
    Arni

    if ( ! function_exists('wp_pagenavi') || is_singular() )
    this was because of TheMadWiddler1200 request, that || is_singular() excludes singulars.
    If you go to the topic linked in my first reply you’ll see the code to replace customizr navigation with wp_pagenavi sitewide (not for comments though)

    Thank you!
    This works well. But unfortunately only for posts level. When post have a long list of comments the pagination for comments still text such us “oldest comments” and “newest comments”. Is the any way to make it numbered?

    P.S. To first question (posts pagination way). I hear that since WP 4.1 function the_posts_pagination can make it without plugins. Is variant with plugin better?

    Regards,
    Arni

    Hi arniarni,
    you can use the_posts_pagination, with something like :

    add_action('wp_head', 'my_post_nav');
    function my_post_nav(){
        remove_action( '__after_loop' , array( TC_post_navigation::$instance , 'tc_post_nav' ), 20 );
        add_action( '__after_loop', 'my_posts_pagination', 20 );
    }
    function my_posts_pagination(){
       /* populate the array of the posts pagination if you need it*/
      $params = array();
      the_posts_pagination($params);
    }

    And about this:

    But unfortunately only for posts level. When post have a long list of comments the pagination for comments still text such us “oldest comments” and “newest comments”.

    Yes, I told you, that code was for the posts nagivation not for comments, for comments you can use pretty the same code, something like (assuming you use the wp-commentnavi plugin, for example):

    add_action('wp_head', 'my_comments_nav');
    function my_comments_nav(){
        if ( ! function_exists('wp_commentnavi') )
            return;
        remove_action( '__comment' , array( TC_comments::$instance , 'tc_comment_navigation' ), 30 );
        add_action( '__comment', 'wp_commentnavi', 30 );
    }

    d4z_c0nf, you are great!
    I am very grateful for your help!
    All works fine!

    Regards,
    Arni

    You’re welcome Arni,
    I’m glad having been helpful ??

    Hi d4z_c0nf,

    Numbered pagination works well (both posts and comments) and thanks one more but I found one SEO problem with permalink of comments navigation (posts pagination works correctly from any page).

    Comment plugin adds page number to permalink of each comment and if some changes be made (for example changes of comments ordering or removal of some comments) then this urls will change too. Example of comments permalink with pagination:
    https://domain.com/postname/comment-page-2/#comment-492

    Do you know any way how correct this problem and make permalink structure like as posts without page numbers?

    Regards,
    Arni

    @arnani: As long as you have Canonical URLs working properly, you won’t have to worry about SEO issues. Each “version” of the page with different groups of comments will still be “seen” by Google as the same URL.

    @d4z_c0nf: Thanks for this excellent tip and code. But does it not work on the grid front page layout?

    Comment pagination works great on one of my blog posts that has over 500 comments:

    https://www.stevejenkins.com/blog/2013/01/my-cisco-linksys-e4200-dd-wrt-settings-for-max-speed/

    But posts pagination doesn’t seem to appear on my home page:

    https://www.stevejenkins.com/blog/

    This is what’s in my functions.php:

    // Paginate Posts
    add_action('wp_head', 'my_post_nav');
    function my_post_nav(){
        if ( !function_exists('wp_pagenavi') )
            return;
        remove_action( '__after_loop' , array( TC_post_navigation::$instance , 'tc_post_nav' ), 20 );
        add_action( '__after_loop', 'wp_pagenavi', 20 );
    }
    
    // Paginate Comments
    add_action('wp_head', 'my_comments_nav');
    function my_comments_nav(){
        if ( ! function_exists('wp_commentnavi') )
            return;
        remove_action( '__comment' , array( TC_comments::$instance , 'tc_comment_navigation' ), 30 );
        add_action( '__comment', 'wp_commentnavi', 30 );
    }
    
    // Add Google Tag Manager and Ad Javacsript to Header
    add_action ('wp_head' , 'add_gtm_script');
    function add_gtm_script() {
    ?>

    I’d appreciate any suggestions. Thanks! ??

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Add numbered pagination to homepage post list nav?’ is closed to new replies.