Info
- 13 posts
- 6 voices
- Started 3 years ago by Tom(dB)
- Latest reply from guly
- This topic is not resolved
How do I exclude a forum category from latest discussions?
-
- Posted 3 years ago #
I managed to do it with
if ($topic->forum_id != 3)
but then it's still counting them as part of the loop therefore it ends up with 'Number of Discussions to display - Number of discussions in that forum'.
How can I do it so it just leaves them out but leaves the latest discussion length intact?
-
- Posted 3 years ago #
come on, someone must know how to do this.
I can limit it to one forum with this:
<?php $topics = get_latest_topics( 1 ); ?>but I want $topics to get forums 1 and 2 (but not 3).
-
- Posted 3 years ago #
Did you try any of the WordPress-style tricks?
<?php $topics = get_latest_topics('exclude=3' ); ?> <?php $topics = get_latest_topics( -3 ); ?> -
- Posted 3 years ago #
of course! why didn't I think of that?
Anyway, thank you very much. You deserve an award. Both those options work.
-
- Posted 3 years ago #
Thanks chrishajer. Option two works in my case. I wonder if it is possible to modify the RSS-output as well, so that posts from the selected category will be excluded in the RSS-feed?
-
- Posted 3 years ago #
I took a look at some of the rss-related files but could not find any ways to do this, but I suppose it must be possible in some way?
-
- Posted 2 years ago #
the latest bleeding edge release (from subversion) adds paging to the 'Latest Discussions'. But if any of the arguments are used in 'get_latest_topics' the paging doesn't work.
from functions.bb-topics.php
function get_latest_topics( $args = null ) { $defaults = array( 'forum' => false, 'page' => 1, 'exclude' => false, 'number' => false );so I've tried it with
$topics = get_latest_topics('forum=-3');
and
$topics = get_latest_topics('exclude=3');
both have same results but no paging. -
- Posted 2 years ago #
Sorry im still confused where did you insert
$topics = get_latest_topics('forum=-3');
in functions.bb-topics.php
or front-page.php -
- Posted 2 years ago #
For those that are interested I found this.
Just edit it to exclude whatever forum numbers you want and add it to the plug-ins folder.<?php
/*
Plugin Name: exclude
*/
function filter_front_page_topics($where){
$exclude_forums=array ("13","19"); // enable this to manually specify specific forums by id #
// $forums = get_forums(); foreach ($forums as $forum) {if ($forum->forum_parent) {$exclude_forums[]=$forum->forum_id;}} // exclude ALL sub-forums
if ( is_front() ) {foreach($exclude_forums as $forum) { $where.=" AND forum_id != ".$forum." "; }}
return $where;
}
add_filter( 'get_latest_topics_where', 'filter_front_page_topics');
add_filter( 'get_latest_posts_where', 'filter_front_page_topics');
?> -
- Posted 2 years ago #
Excellent, thanks for posting this. Just tried it on latest 'bleeding edge' release and it keeps the paging intact.
-
- Posted 2 years ago #
...it does keep the paging intact but counts for all the forums (fora?), even the excluded one(s).
To get round this requires amending the function bb_latest_topics_pages() in functions.bb-template.php.
$bb_latest_topics_count = $bbdb->get_var('SELECT COUNT('topic_id') FROM '' . $bbdb->topics . '' WHERE 'topic_open' = 1 AND 'topic_status' = 0 AND 'topic_sticky' != 2 AND 'forum_id' != 3;'); // AND 'forum_id' != 3 - filters out forum 3 on front page paging count. -
- Posted 2 years ago #
Merlin that code looks vaguely familiar ;-)
-
- Posted 1 year ago #
I found that to exclude multiple forums, it has to be a negative value in exclude:
get_latest_topics('exclude=-3,-16,-28')according to the wordpress codex, the numbers are supposed to be in ascending order, so I assume order is important in bbpress too.
-
You must log in to post.