WordPress page template list all posts


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



Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3. Template Name: All posts
  4. */
  5. ?>
  6. <!-- via bit.ly/wprec-allposts -->
  7. <?php get_header(); ?>
  8. <?php
  9. $debut = 0; //The first article to be displayed
  10. ?>
  11. <?php while(have_posts()) : the_post(); ?>
  12. <h2><?php the_title(); ?></h2>
  13. <ul>
  14. <?php
  15. $myposts = get_posts('numberposts=-1&offset=$debut');
  16. foreach($myposts as $post) :
  17. ?>
  18. <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  19. <?php endforeach; ?>
  20. </ul>
  21. <?php endwhile; ?>
  22. <?php get_sidebar(); ?>
  23. <?php get_footer(); ?>

URL: http://bit.ly/wprec-allposts

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.