More
    Home Design / Dev How to list all posts in a page

    How to list all posts in a page

    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: Archives
    */
    get_header(); ?>
    <div id="primary" class="site-content">
    <div id="content" role="main">
    <?php while ( have_posts() ) : the_post(); ?>
                    
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <div class="entry-content">
    <?php the_content(); ?>
    /* Custom Archives Functions Go Below this line */
    /* Custom Archives Functions Go Above this line */
    </div><!-- .entry-content -->
    <?php endwhile; // end of the loop. ?>
    </div><!-- #content -->
    </div><!-- #primary -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Keep the archives.php file in your theme folder along with where those index.php and all.

    READ ALSO:  15 of the Best Tutorials to Learn WordPress Theme Development
    - Advertisement -

    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!

    READ ALSO:  Disable Comments and Pingbacks in Old Posts

    One example you can see is the archive page on WPTidBits.com here.

    - Advertisement -
    Avatar
    WPTidBitshttps://wptidbits.com/
    Owner of WPTidBits. Totally in love with WordPress!

    1 COMMENT

    1. hello this a good article but I need to display posts of specific category in a page like this example how can i make it

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    110FansLike
    761FollowersFollow

    You May Also Like