Posted By

florent on 10/21/11


Tagged

wordpress categorie


Versions (?)

How to Display Most Popular Posts from a Specific Category


 / Published in: PHP
 

  1. <?php
  2. $args=array(
  3. 'cat' => 3,
  4. 'orderby' => 'comment_count',
  5. 'order' => 'DESC',
  6. 'post_type' => 'post',
  7. 'post_status' => 'publish',
  8. 'posts_per_page' => 6,
  9. 'caller_get_posts'=> 1
  10. );
  11. $my_query = null;
  12. $my_query = new WP_Query($args);
  13. if( $my_query->have_posts() ) { ?>
  14. <ul>
  15. <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  16. <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  17. <?php endwhile; ?>
  18. </ul>
  19. <?php }
  20.  
  21. wp_reset_query(); ?>
  22.  
  23.  

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: infocampus on August 8, 2018

It’s hard to come by experienced people about this subject, but you seem like you know what you’re talking about! Thanks iOS Training in Bangalore

You need to login to post a comment.