Support » Plugins » Show "Top postings" rank number

  • lzz09


    I’m in the process of creating a WordPress theme and I just stumbled upon something I need help for.

    I want to show “top postings” in the sidebar, I’ve coded it already, see screenshot. I got the top postings code snippet from internet and I tweaked it to fit my theme design.
    The ranking of the posts are in order of comment count, which will be retrieved from the database, see the code:

    <?php $popular_posts = $wpdb->get_results("SELECT id, post_title FROM {$wpdb->prefix}posts ORDER BY comment_count DESC LIMIT 0,3"); foreach($popular_posts as $post) { ?>
         <div class="span-1"><span class="rank"><?php print $post->id; ?></span></div>
         <div class="span-5 last"><?php print "<a href='". get_permalink($post->id) ."'>".$post->post_title."</a><br/><br/>\n"; ?></div>
     <?php } ?>

    However, the code snippet didn’t include the code to show the rank number. Temporarily I used the post id (see the code above), at the moment the posts with the ID’s 1,2,3 are also ranked first, second and third respectively. (See screenshot)

    So does anyone know how to show the rank number? I know it’s possible with <ol>...</ol>, but I don’t want lists as it’s not possible to style the ordered list number with css (this way I created with class="rank" a star badge background).

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show "Top postings" rank number’ is closed to new replies.