Display Blog Post on Page Template in WordPress

Blog page usually show the latest post on the home page. But this is not always true on some website.

Most of WordPress developers encounter some situation that they need to put blog posts on a different page.

Here’s a quick code that will enable you to display blog posts on a page except the home page.

 * Template Name: Blog Page
get_header(); ?>

<section class="maincontent">
	<?php	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
	<?php query_posts("paged=$paged"); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
	<article class="blogposts">
		<header id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<h1><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h1>
			<p class="petsa"><time><?php the_date(); ?></time> by <?php the_author(); ?></p>
		<?php the_excerpt(); ?>
	<?php endwhile; ?>
	<?php endif; ?>
<?php get_footer(); ?>

Make sure that you have the settings below.

show posts on your static page in wordpress

Check this settings on Setting > Reading

*Some links may contain affiliate links. I may get small commission from your purchases to fund this website and to avoid annoying ads.