Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I exclude a forum category from latest discussions?


  • Tom(dB)
    Participant

    @tomdebruin

    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?

Viewing 12 replies - 1 through 12 (of 12 total)

  • Tom(dB)
    Participant

    @tomdebruin

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


    chrishajer
    Participant

    @chrishajer

    Did you try any of the WordPress-style tricks?

    <?php $topics = get_latest_topics('exclude=3' ); ?>
    <?php $topics = get_latest_topics( -3 ); ?>


    Tom(dB)
    Participant

    @tomdebruin

    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?


    Tom(dB)
    Participant

    @tomdebruin

    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.


    merlin214365
    Member

    @merlin214365

    Sorry im still confused where did you insert

    $topics = get_latest_topics(‘forum=-3′);

    in functions.bb-topics.php

    or front-page.php


    merlin214365
    Member

    @merlin214365

    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’);

    ?>


    Tom(dB)
    Participant

    @tomdebruin

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


    Tom(dB)
    Participant

    @tomdebruin

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


    _ck_
    Participant

    @_ck_

    Merlin that code looks vaguely familiar ;-)


    guly
    Participant

    @guly

    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.

Viewing 12 replies - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.