Info
- 4 posts
- 3 voices
- Started 2 years ago by anandasama
- Latest reply from anandasama
- This topic is not resolved
Front-page, Latest Discussions (Show/Hide posts from forums)
-
- Posted 2 years ago #
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..
-
- Posted 2 years ago #
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.
-
- Posted 2 years ago #
Have a look here on how to exclude a forum from the front page loop, whilst keeping the post limit intact.
http://bbpress.org/forums/topic/limit-forums-included-in-latest-discussions#post-48615
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: http://codex.wordpress.org/The_Loop#Multiple_Loops)
-
- Posted 2 years ago #
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.
-
You must log in to post.