Skip to main content
edited body
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

On your custom page template, the default loop is working and that's why the loop is fetching content from the page. You need a custom query in this case. Here's the code.

<?php
$query = new WP_Query( array(
    'post_type' => 'post',
    'post_status' => 'publish',
) );
if ( $query->have_posts() ) :{
    while ( $query->have_posts() ) :{
        $query->the_post();
        get_template_part( 'content', 'home' ); 
    endwhile;
endif;}
?>}

On your custom page template, the default loop is working and that's why the loop is fetching content from the page. You need a custom query in this case. Here's the code.

<?php
$query = new WP_Query( array(
    'post_type' => 'post',
    'post_status' => 'publish',
) );
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post();
        get_template_part( 'content', 'home' ); 
    endwhile;
endif;
?>

On your custom page template, the default loop is working and that's why the loop is fetching content from the page. You need a custom query in this case. Here's the code.

<?php
$query = new WP_Query( array(
    'post_type' => 'post',
    'post_status' => 'publish',
) );
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        get_template_part( 'content', 'home' ); 
    }
}
Source Link
obiPlabon
  • 1.7k
  • 7
  • 13

On your custom page template, the default loop is working and that's why the loop is fetching content from the page. You need a custom query in this case. Here's the code.

<?php
$query = new WP_Query( array(
    'post_type' => 'post',
    'post_status' => 'publish',
) );
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post();
        get_template_part( 'content', 'home' ); 
    endwhile;
endif;
?>