I’ve already written about how to display your featured image/post image after your title and excerpt on archive pages but how about displaying the image before your entry title?
In this post, i’ll show you exactly how to display your featured image before your titles on any archive page.
Firstly, here’s the default home page view using the Genesis Sample child theme:
Here’s the code to reposition the post image which goes at the end if your child themes functions.php file:
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_header', 'genesis_do_post_image', 1 );
And here’s the result after adding the PHP code:
The reason the image is aligned left is because of this CSS code which is located on Line 588 of the Sample themes style.css file:
.alignleft {
float: left;
text-align: left;
}
If you remove this CSS, this is how your featured image looks.
Which is the solution this post is focused on however removing the CSS code may effect other elements using that class so here’s another solution.
Please copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++
Credit to Bill Erickson for this code.
Leave a Reply
You must be logged in to post a comment.