Posted By

paul0078 on 04/15/12


Tagged

list wordpress posts


Versions (?)

List of latest posts


 / Published in: PHP
 

  1. // Function to display list of latest news articles
  2. function latest_news_list($count) {
  3. ?>
  4. <h3>latest news</h3>
  5. <ul>
  6. <?php
  7. global $post;
  8. $args = array( 'numberposts' => $count, 'offset'=> 0, 'category' => 1 );
  9. $myposts = get_posts( $args );
  10. foreach( $myposts as $post ) : setup_postdata($post); ?>
  11. <!-- <p class="date"><?php the_date(); ?></p> -->
  12. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  13. <?php endforeach; ?>
  14. </ul>
  15. <?php
  16. }
  17. ?>

Report this snippet  

You need to login to post a comment.