Skip to:
Content
Pages
Categories
Search
Top
Bottom

Pagination – How to remove last page numbers?


  • kriskl
    Participant

    @kriskl

    Hi,

    I would like to remove the last page numbers in pagination,
    is there any function code to do this?

    at the moment, on latest topics on a big forum.. it shows like this..

    1 2 3… 8432 8442 8445 β†’

    Thanks
    kris

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

  • Robin W
    Moderator

    @robin-w

    link to an example and I might be able to give you css to hide


    kriskl
    Participant

    @kriskl

    Hi Robin,

    for example on this page:

    https://bbpress.org/forums/

    to remove / hide 981 982 983 pages

    the css class seems to be the same, so not sure how to hide it


    Robin W
    Moderator

    @robin-w

    yes I see πŸ™‚

    Put this in your child theme’s function file – or use

    Code Snippets

    add_filter ('bbp_before_paginate_links_parse_args' , 'rew_pagintion' ) ;
    
    function rew_pagintion ($args) {
    	$args['end_size'] = 0 ;
    return $args;
    }

    kriskl
    Participant

    @kriskl

    Thanks for quick reply,

    I have just tried the code and nothing has changed :((


    Robin W
    Moderator

    @robin-w

    in your functions file or code snippets ?


    kriskl
    Participant

    @kriskl

    In the functions file

    – I can increase the number of β€œpages” but 0 doesn’t work


    Robin W
    Moderator

    @robin-w

    so the functions.php file that is in your child theme – yes ? (sorry but the obvious questions so often lead me to a solution!)

    and can you paste the code with say the function above or below it, so I can check that it is not erroring due to syntax.


    kriskl
    Participant

    @kriskl

    hi,

    yes it is in the correct child theme πŸ™‚

    I have also tried this code – which seems similar to yours, and I can make more page numbers – front and end. but I can’t remove the end with 0

    function ra_bbp_increase_pagination($args) {
        $args['end_size'] = 0;
        $args['mid_size'] = 2;
        return $args;
    }
    add_filter( 'bbp_topic_pagination', 'ra_bbp_increase_pagination' );

    Robin W
    Moderator

    @robin-w

    hmm end works with 0 on my test site !


    kriskl
    Participant

    @kriskl

    yhm,
    I will try on another test site
    maybe some plugin conflict..
    here is some code above and below

    //ONLY BBPress below
    //create vertical list subforum layout
    function custom_bbp_sub_forum_list() {
      $args['separator'] = '
    ';
      return $args;
    }
     add_filter('bbp_after_list_forums_parse_args', 'custom_bbp_sub_forum_list' );
     
    
    function ra_bbp_increase_pagination($args) {
        $args['end_size'] = 0;
        $args['mid_size'] = 3;
        return $args;
    }
    add_filter( 'bbp_topic_pagination', 'ra_bbp_increase_pagination' );
    
    function rk_hot_topics() {
       $reply_count = bbp_get_topic_reply_count();
      
       if ( $reply_count > 5 )
          echo '<span class="hot">HOT</span>';
    }
      
    add_action( 'bbp_theme_before_topic_title', 'rk_hot_topics' );

    kriskl
    Participant

    @kriskl

    it does not work on another site with 0 πŸ™

    I am using genesis framework by the way.


    Robin W
    Moderator

    @robin-w

    ok, so did you try MY code on another site?


    kriskl
    Participant

    @kriskl

    yes,

    I have disabled all plugins but BBpress. and changed to WordPress default theme.
    with your code
    this is what it looks like:

    1 2 … 2,843 β†’
    it still shows the last page: 2,843

    https://opendev.leetdns.com/forums/


    Robin W
    Moderator

    @robin-w

    hmm – that’s a core WordPress bug.

    It has a track ticket, but no date

    https://core.trac.wordpress.org/ticket/39251

    sorry, best I can do !!


    kriskl
    Participant

    @kriskl

    I see, pity, but thanks for your help πŸ™‚

    BY the way, How on this BBpress forums – it was possible to remove top pagination and leaving the one at the bottom?

    css display none kills both πŸ™


    Robin W
    Moderator

    @robin-w

    yes, find
    wp-content/plugins/bbpress/templates/default/bbpress/content-single-forum.php

    transfer this to your pc and edit

    you’ll see

    <?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    <?php bbp_get_template_part( 'loop',       'topics'    ); ?>
    
    <?php bbp_get_template_part( 'pagination', 'topics'    ); ?>

    change that to take out the first line and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/content-single-forum.php

    bbPress will now use this template instead of the original


    Robin W
    Moderator

    @robin-w

    oh, and I found a bit where we can do some string editing, so…

    This code reduces the last to 1 entry, and then looks for that entry and removes it…

    add_filter ('bbp_before_paginate_links_parse_args' , 'rew_pagintion' ) ;
    
    function rew_pagintion ($args) {
    	$args['end_size'] = 0 ;
    return $args;
    }
    
    add_filter ('bbp_make_first_page_canonical', 'rew_take_out_last', 10 ,2) ;
    
    function rew_take_out_last ($retval, $pagination_links) {
    	$posf = strrpos ($pagination_links, '<a class="page-numbers' ) ;
    	$posl = strpos ($pagination_links, '<a class="next page-numbers' ) ;
    	$start = substr ($pagination_links, 0 , $posf) ;
    	$end = substr ($pagination_links, $posl , strlen($pagination_links)) ;
    	$links = $start.$end ;
    return $links ;
    }

    you can get rid of the page number dots using css or some more str functions in the code above, but I’ll leave you to work that out πŸ™‚


    kriskl
    Participant

    @kriskl

    oh Robin, you are a star! πŸ™‚

    the code did wonders.

    I’ll leave the dots as they make sense when going through the pages later.. so it’s consistent.

    and thanks! I was so silly, not realising about editing out the code
    <?php bbp_get_template_part( ‘pagination’, ‘topics’ ); ?>
    in templates

    I thought there was some function code trick :))

    I hope you have a nice weekend, thanks again!

    ps. maybe you should add this filter as an option
    add_filter (‘bbp_before_paginate_links_parse_args’ , ‘rew_pagintion’ ) ;

    in your plugin?

    it seems many users might find it useful


    Robin W
    Moderator

    @robin-w

    great – really pleased that we got there – it was nagging me that I couldn’t do it so I took another look – glad you are fixed !!


    kriskl
    Participant

    @kriskl

    Hi Robin,

    Sorry to re-open this.

    the latest topics pagination works great! thanks to the code above,

    BUT when I turned off threaded replies. the normal pagination in topics is strange..

    here is what I mean

    https://opentuition.com/forums/

    the page numbers it shows are : 1, 2, 4
    instead of 1, 2, 3, 4, or 1,2, 4

    and when I go to some topic

    and click on page 3
    it shows like this:

    1, 1, 2, 3

    here is the example

    https://opentuition.com/topic/obu-period-40-results-post-your-comments-instant-poll/page/3/

    is there anything that can be done? do you think?

    thanks
    Kris


    Robin W
    Moderator

    @robin-w

    ate you still running the threaded replies plugin I did a few days ago? that’s designed to work with threaded replies turned on, no idea what it does if you turn threaded replies off and leave it active.

    Both it and the code above hook to the same link.


    kriskl
    Participant

    @kriskl

    hi, no, I had to turn off threaded replies feature of BBpress and therefore the plugin
    as some users were complaining πŸ™

    it was difficult for them to find recent replies in topics where there were 50 or more replies..

    do you think I should turn the plugin back on?


    kriskl
    Participant

    @kriskl

    I guess, one way to fix it would be to change number of replies in a topic to 100 or 200

    if there is no easy fix


    Robin W
    Moderator

    @robin-w

    no – with threaded replies plugin deactivated and threaded replies (TR) turned off it should work.

    I presume it worked 2 months ago?

    I also have no idea how bbpress does replies that have previously been threaded and now TR has been turned off. might that be the issue?


    kriskl
    Participant

    @kriskl

    2 months ago it worked OK, because threaded replies on BBpress was enabled

    yesterday/today I have turned it off, only then when I have noticed it

Viewing 25 replies - 1 through 25 (of 25 total)
  • You must be logged in to reply to this topic.
Skip to toolbar