• RB9

    (@rb9)


    I have a custom page for my wordpress theme named “page-Blog.php” in the theme folder. In this page I want to show all post. I am using this code in “index.php” and “page-Blog.php” to show all post, but in “page-Blog.php” its not working but it is working in “index.php”:

    <?php get_header(); ?>
    <?php
     if ( have_posts() ) :
           while(have_posts()) : the_post();
               the_title();  // to show the title of the post
               the_content();   //to show the content of the post
           endwhile;
    endif; ?>
    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
  • use template name in page-blog.php like this

    <?php
    /*Template Name:My Blog*/
    ?>
    <?php get_header(); ?>
    <?php
     if ( have_posts() ) :
           while(have_posts()) : the_post();
               the_title();  // to show the title of the post
               the_content();   //to show the content of the post
           endwhile;
    endif; ?>
    <?php get_footer(); ?>

    Now from dashboard go to Setting -> Reading -> choose A Static page -> click dropdown of Posts page and click My Blog(our template name) -> save changes

    Now all blog posts will show in page-blog.php
    Done!

Viewing 1 replies (of 1 total)
  • The topic ‘How do I show all post in my custom page in wordpress?’ is closed to new replies.