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).
Did you try any of the WordPress-style tricks?
<?php $topics = get_latest_topics('exclude=3' ); ?>
<?php $topics = get_latest_topics( -3 ); ?>
of course! why didn’t I think of that?
Anyway, thank you very much. You deserve an award. Both those options work.
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?
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?
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.
Sorry im still confused where did you insert
$topics = get_latest_topics(‘forum=-3’);
in functions.bb-topics.php
or front-page.php
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’);
?>
Excellent, thanks for posting this. Just tried it on latest ‘bleeding edge’ release and it keeps the paging intact.
…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.
Merlin that code looks vaguely familiar
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.
I know this is a topic dredge but would the same code work for excluding particular forums from search results?