Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I loop through EACH forum?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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; ?>

    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.

    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.

    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>

    Man you rock!

    thanks a bunch for this.

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