PHP – WordPress – Get Posts from Category

The given PHP example is for getting a specific number of posts from a specific category, 
it is useful for news listing in sidebar.

Code Example:
    global $post;
    $myposts = get_posts('numberposts=6&category=3');
    foreach($myposts as $post) :
    <div class="news_ticker_articles">
      <p><strong> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
        <?php the_title(); ?>
        </a> </strong></p>
      <p class="excerpt_bottom"><? echo bm_better_excerpt(100, '...'); ?></p>
  <?php endforeach; ?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *