List all wordpress posts on a page
November 20, 2008 · Print This Article
How we can create a table of content for his WordPress blog?
Here’s a simple code which can also be used to create an archive page.
To achieve this recipe, you first need to create a page template.
First, on this page template, paste the following code;
Then, login to your WordPress dashboard, write a new page and select this page as a template.
<?php
/*
Template Name: All posts
*/
?>
<?php
$debut = 0; //The first article to be displayed
?>
<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<ul>
<?php
$myposts = get_posts('numberposts=-1&offset=$debut');
foreach($myposts as $post) :
?>
<li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<?php endwhile; ?>
Comments
Got something to say?
You must be logged in to post a comment.