Info
- 9 posts
- 3 voices
- Started 4 years ago by glanceup
- Latest reply from citizenkeith
- This topic is not resolved
How to restrict number of Latest Discussions on front page
-
- Posted 4 years ago #
Hi. I'm using 9.0.1. I would like to restrict the number of Latest Discussions showing to 5. How do I do this? I don't see anything in the bb-config file and the Front Page Topics plugin doesn't seem to work with 9.0.1...
Your help appreciated.
-
- Posted 4 years ago #
Front page topics plugin isn't working? Hmm. Should be.
I have a modification I've done somewhere...
Try this:
// fix number of front page topics function bb_custom_topic_limit($limit) { switch (bb_get_location()) : case 'front-page': $limit=5; break; case 'forum-page': $limit=10; break; case 'tag-page': break; case 'topic-page': $limit=15; break; case 'feed-page': break; case 'search-page': break; case 'profile-page': break; case 'favorites-page': break; case 'view-page': $limit=10; break; case 'stats-page': break; case 'login-page': break; default: $limit=15; endswitch; return $limit; } add_action( 'bb_get_option_page_topics', 'bb_custom_topic_limit',200); // required to fix for custom topic limits to calculate correct page jumps function fix_post_link ($link,$post_id) { global $topic; remove_action( 'bb_get_option_page_topics', 'bb_custom_topic_limit' ); if ($topic && $topic->topic_last_post_id==$post_id) { $topic_id=$topic->topic_id; $page=get_page_number( $topic->topic_posts ); } else { $bb_post = bb_get_post( get_post_id( $post_id ) ); $topic_id=$bb_post->topic_id; $page = get_page_number( $bb_post->post_position ); } return get_topic_link( $topic_id, $page ) . "#post-$post_id"; } add_filter( 'get_post_link','fix_post_link',10, 2); -
- Posted 4 years ago #
ck -- Into what file and where do I paste that code? Thanks. PS I am using bbPress 9.0.1
-
- Posted 4 years ago #
glanceup: Just cut and paste it into a plugin template. Here's what I did (apologies to _ck_ if the headers aren't quite right):
<?php /* Plugin Name: Fix Number of Front Page Topics Plugin URI: http://bbpress.org/forums/topic/how-to-restrict-number-of-latest-discussions-on-front-page Description: Fix Number of Front Page Topics Author: _ck_ Author URI: http://bbshowcase.org/ Version: 0.1 */ // fix number of front page topics function bb_custom_topic_limit($limit) { switch (bb_get_location()) : case 'front-page': $limit=5; break; case 'forum-page': $limit=10; break; case 'tag-page': break; case 'topic-page': $limit=15; break; case 'feed-page': break; case 'search-page': break; case 'profile-page': break; case 'favorites-page': break; case 'view-page': $limit=10; break; case 'stats-page': break; case 'login-page': break; default: $limit=15; endswitch; return $limit; } add_action( 'bb_get_option_page_topics', 'bb_custom_topic_limit',200); // required to fix for custom topic limits to calculate correct page jumps function fix_post_link ($link,$post_id) { global $topic; remove_action( 'bb_get_option_page_topics', 'bb_custom_topic_limit' ); if ($topic && $topic->topic_last_post_id==$post_id) { $topic_id=$topic->topic_id; $page=get_page_number( $topic->topic_posts ); } else { $bb_post = bb_get_post( get_post_id( $post_id ) ); $topic_id=$bb_post->topic_id; $page = get_page_number( $bb_post->post_position ); } return get_topic_link( $topic_id, $page ) . "#post-$post_id"; } add_filter( 'get_post_link','fix_post_link',10, 2); ?> -
- Posted 4 years ago #
However, fel64's "Page" plugin doesn't work after activating this one:
-
- Posted 4 years ago #
Oh, excitement! That seems to work just fine. Thank you.
-
- Posted 4 years ago #
Thanks to Sam, I learned that the Freshness column links to the latest post, so fel64's Page plugin is no longer necessary.
However, when I activate _ck_'s Front Page Posts plugin, the freshness column links to a page without any posts.
_ck_ (or anybody who wants to troubleshoot) can contact me for a login and password for my forum. kamera [at] gmail will do the trick.
-
- Posted 4 years ago #
My educated guess would be because fel64's plugin is grabbing the link within the title, so the plugin that alters the page count is not getting unhooked yet.
Try adding on a new line after
global $topic;in fel64's plugin:
remove_action( 'bb_get_option_page_topics', 'bb_custom_topic_limit', 200);It's occurred to me there might be a bug in my plugin where I don't have that matching
,200on the end of the same remove_action line. If I remember correctly, actions have to be unhooked with matching priority numbers to how they were added. So maybe try adding the,200also.Remember that bbPress's "topics per page" setting must be set to the actual number of posts you want listed on a topic page.
-
- Posted 4 years ago #
That worked! Thanks _ck_!!
-
You must log in to post.