I’m new to Wordpress and created a custom home page and separate blog page, but wanted to include 5 posts on home page - one featured and four of the latest. Finally got it to work with the code below (ignore the classes - that’s just my CSS):
<?php
$the_slug = 'featured-post';
$args=array(
'name' => $the_slug,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1
);
$postslist = get_posts( $args );
foreach ( $postslist as $post ) :
setup_postdata( $post ); ?>
<div class="home-primary-post">
<div class="home-primary-title"><?php the_title(); ?></div>
<div class="home-primary-date"> <?php the_date(); ?></div>
<div class="home-primary-excerpt"><?php the_excerpt(); ?></div>
</div>
<?php
endforeach;
wp_reset_postdata();
?>
<?php
$args = array( 'posts_per_page' => 4, 'order'=> 'ASC', 'orderby' => 'title' );
$postslist = get_posts( $args );
foreach ( $postslist as $post ) :
setup_postdata( $post ); ?>
<div class="home-secondary-post">
<div class="home-secondary-title"><?php the_title(); ?></div>
<div class="home-secondary-date"> <?php the_date(); ?></div>
<div class="home-secondary-excerpt"><?php the_excerpt(); ?></div>
</div>
<?php
endforeach;
wp_reset_postdata();
?>