Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to Show Last Ten Posts in Sidebar?

  • @bbisimone

    Member

    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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • @chandersbs

    Member

    You mean the last 10 replies?

    @bbisimone

    Member

    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/

    @kawauso

    Member

    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.

    @chandersbs

    Member

    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.

    @ashfame

    Participant

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

    @chandersbs

    Member

    Like?

    @gerikg

    Member

    @chandersbs

    Member

    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 "

  • topic_id."'>".$result->topic_title." (".$result->topic_posts.")
  • ";

    }

    ?>

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

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