Usually, when we develop websites in WordPress, we can choose between two options:
- Have a static home page
- Have a blog on the home page and show the most recent post
Recently I was working on a website that had a different requirement. In this case it was important to have a static home page and at the same time show the most recent blog posts below the static home page.
After some research, I found the following website that includes an excellent explanation of how to achieve this change: : http://sridharkatakam.com/show-latest-posts-content-homepage-genesis/
In order to do this, one has to register a new widget area called: Home Below Content, and then one drags the widget from Features posts in Genesis to the recently created widget in Home Below Content.
These are the steps I followed:
- Create the widget Home Below Content
In order to do this it is necessary to add the following code to functions.php inside the child theme:
// Register widget area
genesis_register_sidebar( array(
'id' => 'home-below-content',
'name' => __( 'Home Below Content', 'genesis' ),
'description' => __( 'This is the home below content section.', 'genesis' ),
) );
//* Add the Home Below Content section
add_action( 'genesis_entry_content', 'sk_show_posts' );
function sk_show_posts() {
if ( is_front_page() ) {
printf( '<div %s>', genesis_attr( 'home-below-content' ) );
genesis_widget_area( 'home-below-content' );
echo '</div>';
}
}
//* Modify the Excerpt read more link
function new_excerpt_more($more) {
return '<a class="more-link" href="' . get_permalink() . '"> [Continue Reading]</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
2. Add the following code to the style.css file that corresponds to the child theme:
.entry-content a.alignleft,
.entry-content a.more-link {
border-bottom: none;
}
.entry-content a.alignleft img {
margin-right: 2rem;
}
.home .entry-content .widget-title {
font-size: 3.6rem;
text-transform: none;
}
2. On the WordPress dashboard, go to Appearance>Widgets, drag the widget in Featured Posts to the widget Home Below Content. Once this is completed, it is possible to configure it. For example, it is possible to specify the categories one wants to show, the number of posts, it one wants to include a thumbnail for an image, etc.
3. Update the website in the browser and enjoy the results.