Pagination – How to remove last page numbers?
-
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
-
link to an example and I might be able to give you css to hide
Hi Robin,
for example on this page:
to remove / hide 981 982 983 pages
the css class seems to be the same, so not sure how to hide it
yes I see π
Put this in your child theme’s function file – or use
add_filter ('bbp_before_paginate_links_parse_args' , 'rew_pagintion' ) ; function rew_pagintion ($args) { $args['end_size'] = 0 ; return $args; }
Thanks for quick reply,
I have just tried the code and nothing has changed :((
in your functions file or code snippets ?
In the functions file
– I can increase the number of βpagesβ but 0 doesnβt work
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.
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' );
hmm end works with 0 on my test site !
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' );
it does not work on another site with 0 π
I am using genesis framework by the way.
ok, so did you try MY code on another site?
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,843hmm – 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 !!
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 π
yes, find
wp-content/plugins/bbpress/templates/default/bbpress/content-single-forum.phptransfer 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%/bbpresswhere %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.phpbbPress will now use this template instead of the original
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 π
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 templatesI 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
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 !!
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, 4and 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
Krisate 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.
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?
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
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?
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
- You must be logged in to reply to this topic.