Forums

Join
bbPress Support ForumsInstallationHow do I loop through EACH forum?

Info

How do I loop through EACH forum?

  1. how do i loop through each forum to echo the latest topics for each one seperatly... rather than blast out the entire topics of every forum at once.

  2. I didn't find how to loop each category if there is such as thing, but I found this solution, its WORKS fine...

    <?php if ( $topics ) : foreach ( $topics as $topic) : ?>
    				<?php
    				$doof = $topic->forum_id;
    				if ($doof=="1") {
    				?>
    				<p><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?></p>
    				<?php } ?>
    		<?php endforeach; endif; ?>
  3. Still a problem, becuase the above solution spits out all the topics and not only 3 as Required..

    can anyone help, on how to do a FOR loop for this, i dont get how the array $topics works?

    please help.

    • Initialize a variable as zero.
    • Increment it every time you display a topic (every iteration) if the value of variable is less than 3.
    • As soon as it grows >3, breaks out of the loop.
  4. if you know how to do this please, show me, <?php topic_title(); ?> seems as though it can only be used in a that foreach loop, i cant do a for loop and add ing <?php topic_title(); ?> inside of it.

  5. Although I havn't tested it but it should work:

    <ul>
    <?php
    $count=0;
    if ( $topics )
    {
    	foreach ( $topics as $topic)
    	{
    		$doof = $topic->forum_id;
    		if ($doof=="1")
    		{
    			if($count<3)
    				$count++;
    			else
    				break;
    ?>			<li><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a> | <?php topic_page_links(); ?></li>
    <?php	} } } ?>
    </ul>
  6. Man you rock!

    thanks a bunch for this.

  7. You must log in to post.