Forums

Join
bbPress Support ForumsTroubleshootingHow to Show Last Ten Posts in Sidebar?

Info

How to Show Last Ten Posts in Sidebar?

  1. I'm trying to show the last ten posts in my sidebar, but I am not entirely succeeding, what am I doing wrong? I thought I'd just need to adjust the code from latest discussion a bit. Obviously it doesn't work like that.

    <table class="recent_posts" cellspacing="0" width="100%">
    	<?php if ( $topics ) : foreach ( $topics as $topic ) : ?>
    		<tr<?php topic_class(); ?>>
    			<td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>
    			<td><small><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></small></td>
    		</tr>
    	<?php endforeach; endif; // $topics ?>
    </table>

    So how can I call the latest ten posts in the sidebar?

  2. You mean the last 10 replies?

  3. Nope just the last ten posts that were started. Since you cannot see those from the single topic. Flickr's a good example: http://www.flickr.com/help/forum/en-us/93226/

  4. That code seems to work fine here, what problems are you having? Apart from not having any limiter to keep it at 10 topics anyway.

  5. i tried this code as well, to generate a list of 10 last topics in my sidebar. But its not showing any topics at all.

  6. That might be interfering with the loop. try with a new query variable

  7. Like?

  8. Yeah, it has some very AWESOME code in there, this code generates a list of topics that was active as last:

    <?php if ( bb_forums() ) : ?>
    <h3>Actieve onderwerpen</h3>
    <ul style="color:#bbb;">
    <?php
    global $bbdb;
    $query="SELECT * FROM bb_topics WHERE topic_status=0 ORDER BY topic_time DESC LIMIT 5";
    $results=$bbdb->get_results($query);
    foreach ($results as $result) {
    echo "

  9. topic_id."'>".$result->topic_title." (".$result->topic_posts.")
  10. ";
    }
    ?>

    <?php endif; ?>

    I did some adjustment in the code, to make it work. SWEET.

    But not really what I was looking for, but o well.

  • You must log in to post.