get_posts - reset post list after finished


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <ul>
  2. <?php
  3. global $post;
  4. $tmp_post = $post;
  5. $myposts = get_posts('posts_per_page=5&offset=1&category=1');
  6. foreach($myposts as $post) :
  7. setup_postdata($post);
  8. ?>
  9. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  10. <?php endforeach; ?>
  11. <?php $post = $tmp_post; ?>
  12. </ul>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.