This is how you would do it. You’re loop is based on being in an archive or index page. (or home)
$args = array(
'posts_per_page' => 3,
'post_type' => 'post', //choose post type here
'order' => 'DESC',
);
// query
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
while( $the_query->have_posts() ) : $the_query->the_post();
get_template_part('loop');
endwhile;
else :
endif;
revised code running full query without the content-part.php
// WP_Query arguments
$args = array(
'posts_per_page' => 3,
'post_type' => 'post', //choose post type here
'order' => 'DESC',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="https://wordpress.stackexchange.com/questions/262286/<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="h-entry__image-link">
<?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<!-- post title -->
<h2 class="p-name">
<a href="https://wordpress.stackexchange.com/questions/262286/<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<!-- /post title -->
<!-- post details -->
<time datetime="<?php the_time('Y-m-j'); ?>" class="dt-published"><?php the_time('jS F Y'); ?></time>
<!-- /post details -->
<?php html5wp_summary('html5wp_index'); // Build your custom callback length in functions.php ?>
<p><a href="https://wordpress.stackexchange.com/questions/262286/<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="arrow-link">Read the full article</a></p>
<?php edit_post_link(); ?>
</article>
<!-- /article -->
<?php
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
i can’t fully test it because of the functions being called by your theme, but try it out.
If this does work you you can pull out the article content. Replace all the content in your current loop.php with the content above but only from
<!-- article -->
to
<!-- /article -->
Since that would be in your new loop.php, you’ll take it out of the main page.