There might be a situation where a WordPress blog visitor would want to see an archive page with a complete list of all posts in a page. Not only they can be of help to widen the scanning area of which post they might want to read, but also improving the time of visitors at a certain page or post in terms of SEO because they have a wide list of posts to read after that by directly going to the archive page. The only drawback to it is the page would take quite some time to load all the complete post in the blog if they contain lots of images or videos. We can always use excerpt to level that. Follow us on how to list all posts in a page like our archives page!
To achieve this purpose simply create a .php extension file according to whatever name you like. In this example, name it archives.php. Paste the code below onto it. Name the template as All posts or whatever you like.
<?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; ?>
Keep the archives.php file in your theme folder along with where those index.php and all.
Login to your WordPress admin, create a new page. On the right side, there will be an option to select which template you want to use for the page. Use All posts.
You should be done right now. Publish. That’s it!
One example you can see is the archive page on WPTidBits.com here.