Forums

Join
bbPress Support ForumsTroubleshootingHow do I exclude a forum category from latest discussions?

Info

How do I exclude a forum category from latest discussions?

  1. 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?

  2. 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).

  3. Did you try any of the WordPress-style tricks?

    <?php $topics = get_latest_topics('exclude=3' ); ?>
    <?php $topics = get_latest_topics( -3 ); ?>
  4. of course! why didn't I think of that?

    Anyway, thank you very much. You deserve an award. Both those options work.

  5. 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?

  6. 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?

  7. 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.

  8. Sorry im still confused where did you insert
    $topics = get_latest_topics('forum=-3');
    in functions.bb-topics.php
    or front-page.php

  9. 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');
    ?>

  10. Excellent, thanks for posting this. Just tried it on latest 'bleeding edge' release and it keeps the paging intact.

  11. ...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.
  12. Merlin that code looks vaguely familiar ;-)

  13. 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.

  14. You must log in to post.