Skip to:
Content
Pages
Categories
Search
Top
Bottom

Front-page, Latest Discussions (Show/Hide posts from forums)

  • One thing I have an issue with is the first page; I want to make an own “Latest Discussions” loop with all forums EXCEPT one forum. And then an own “latest discussions” With only the entries on that one forum (It’s linked in RSS posts) on the same page.

    Problem is When i used this inside the loop

    //Show latest discussions with all forums except id 17

    <?php if ( $topics ) : foreach ( $topics as $topic ) : ?>

    <?php if( $topic->forum_id != 17 ) { ?>

    codeblock

    <?php } endif;?>

    <?php endforeach; endif; // $topics ?>

    //Show latest discussions but only forum 17

    <?php if ( $topics ) : foreach ( $topics as $topic ) : ?>

    <?php if( $topic->forum_id == 17 ) { ?>

    codeblock

    <?php } endif;?>

    <?php endforeach; endif; // $topics ?>

    The pagination gets an error (Shows me fewer posts than the actual limit), and I cant use the same loop (With different conditions) twice.. Then I get a blank page. :S

    So how should I do? Have any Idea? Im not so used to the bbpress loop yet..

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

  • r-a-y
    Participant

    @r-a-y

    Just looking at your code, it looks like you’re ending your “if” statement a little early.

    Try this:

    //Show latest discussions with all forums except id 17
    <?php if ( $topics ) : foreach ( $topics as $topic ) : if( $topic->forum_id != 17 ) : ?>
    <!-- your output stuff here -->
    <?php endif; endforeach; endif; // $topics ?>

    //Show latest discussions but only forum 17
    <?php if ( $topics ) : foreach ( $topics as $topic ) : if( $topic->forum_id == 17 ) : ?>
    <!-- your output stuff here -->
    <?php endif; endforeach; endif; // $topics ?>

    Not sure if that’s causing your problems… but try it out and see what happens.


    deadlyhifi
    Participant

    @tomdebruin

    Have a look here on how to exclude a forum from the front page loop, whilst keeping the post limit intact.

    limit forums included in latest discussions

    Note the core hack required to keep the paging numbers correct.

    Maybe you then need to write another small custom query to bring out just forum 17, as I’m not sure you if you can have two loops. (perhaps the WP multiple loop info would give some insight into this: https://codex.wordpress.org/The_Loop#Multiple_Loops)

    In WordPress you need to Rewind posts for faking multiple loops but it doesn’t exist in BbPress?

    @tom thanks for the core hack. I will try it, and then write a custom query for forum 17 with no pagination.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar