Can you only use the LOOP once per page.
-
if you goto the frontpage.php at http://www.massbase.com… on the side bar to the right, (which is the footer.php) there is an extra loop that shows the instant classifed forums (in the black box)…
however if i click on any topic or any page on the site… that loop stops displaying the topics of that forum..
how come ?
this is the code im using for the loops in that black box (which is the same code for all the forums on the frontpage)
<h3 style="color: red;"><?php forum_name(4); ?></h3>
<?php
$count=0;
if ( $topics )
{
foreach ( $topics as $topic)
{
if ($topic->forum_id=="4")
{
if($count<5)
$count++;
else
break;
?>
<br />- <?php bb_topic_labels(); ?> <a style="font-weight:bold; color: white;line-height: 2.5em;" href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?>
<?php
}
}
}
?>
<br /><br /><a id="sub-link" href="<?php bb_uri(); ?>forum/instant-classified"> View all General Topics</a>
-
the right sidebar is just the footer.php
Because the loop relies on the
$topics
global being set by the base index.php file.$topics = get_latest_topics(false, $page);
You can add this to your template if you like just above that loop, to make sure $topics is always available…
if ( !isset( $topics ) ) {
$topics = get_latest_topics( false, 1 ); // Only fetch the first page
}thanks sam it works.
now i can loop through certain forums anywhere on the site.
many thanks for everything.
guys check it out http://www.massbase.com
you can do anything with bb-press.
Its just code that works. Real power is the pluggable nature of bbPress & WordPress which lets you add almost any functionality without bloating the code for mass consumption.
- You must be logged in to reply to this topic.