Posted By

i-am-andy on 08/23/11


Tagged

php wordpress


Versions (?)

Get Posts from Category


 / Published in: PHP
 

Useful snippet for getting a specific number of posts from a specific category, useful for news listing in sidebar

  1. <ul>
  2. <?php
  3. global $post;
  4. $myposts = get_posts('numberposts=6&category=3');
  5. foreach($myposts as $post) :
  6. setup_postdata($post);
  7. ?>
  8. <li>
  9. <div class="news_ticker_articles">
  10. <p><strong> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
  11. <?php the_title(); ?>
  12. </a> </strong></p>
  13. <p class="excerpt_bottom"><? echo bm_better_excerpt(100, '...'); ?></p>
  14. </div>
  15. </li>
  16. <?php endforeach; ?>
  17. </ul>

Report this snippet  

You need to login to post a comment.