Return to Snippet

Revision: 50466
at August 23, 2011 22:16 by i-am-andy


Initial Code
<ul>
    <?php
    global $post;
    $myposts = get_posts('numberposts=6&category=3');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
  <li>
    <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>
    </div>
  </li>
  <?php endforeach; ?>
</ul>

Initial URL

                                

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

Initial Title
Get Posts from Category

Initial Tags
php, wordpress

Initial Language
PHP