treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress Popular Posts section thru Facebook comment count

  • Hi guys,

    I'm trying to display a popular posts list on my sidebar. I wanted to have a popular posts list having the most Facebook comments count. Here's my current code that I have right now but it seems working correctly, is there anything I need to change?


    <?php
    $pc = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>

    <?php while ($pc->have_posts()) : $pc->the_post(); ?>
    <li class="clearer">
    <div id="sb_pp_thumb"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?></a>
    </div>
    <div id="sb_pp_title">
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    <p class="comment_count"><fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count> Comments</p>
    </div>
    </li>

    <?php endwhile; ?>
    </ul>


    Thanks in advance! :)

    Val
  • Any ideas guys? :)
  • What's not working?

    Also don't forget to use wp_reset_postdata(); after the endwhile;