How to Display Featured Image Before or After Entry Title in Genesis

Featured Image Before or After the Entry Title in Genesis

Learn how to add featured image to a single post or a page in Genesis child themes. You can set it to display featured image, before or after your title on single posts.

Images are very important for enhancing the appearance of your posts. Adding images in the post benefits you in various ways including increasing the unique visitors.

WordPress CMS has a popular feature named Featured images also known as post thumbnails. The featured image (Post Thumbnail) is pulled from the featured image paying little respect to how you include it in your Edit Post screen.

The image showed earlier or after your single post passage title is pulled from the first image you embed into the post unless you evacuate it.

You can evacuate or alter the code which shows an image earlier or after your single post section titles utilizing one of the code snippets on this page. In the event that you add a picture as a featured image, it will be shown as a post thumbnail and not as a featured image after your single post’s title.

If you don’t include a highlighted picture, the first picture in your post will be shown earlier or after your single post entry titles and additionally on your chronicle pages.

In this post, I’ll give you lines of PHP code you can basically paste at the end of your theme’s functions.php file.

Using the code, you can display featured image, before or after your title on single posts.

Displaying featured image after the title in Genesis:

To display featured image after the title, paste the following code:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
 if ( ! is_singular( 'post' ) ) return;
 the_post_thumbnail('post-image');
}
// Display featured image below title on the single post in Genesis 
add_action( 'genesis_entry_content', 'featured_post_image', 8 );

Displaying featured image before the title:

If you want to show the featured image before the title, you have to use this code:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
 if ( ! is_singular( 'post' ) ) return;
 the_post_thumbnail('post-image');
}
// Display featured image before title on the single post in Genesis 
add_action( 'genesis_entry_header', 'featured_post_image', 8 );

Using the code above, you can show the image before your single post title.

Add Featured Image on Static Pages only:

There are various reasons why people desire to have a static page on their website. If you also want to show featured image on a static single page, use the following code:

Featured Image

Before title:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
if ( ! is_singular( 'page' ) ) return;
the_post_thumbnail('post-image');
}
// Display featured image before title on the single page in Genesis 
add_action( 'genesis_entry_header', 'featured_post_image', 8 );

Featured Image After title:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
if ( ! is_singular( 'page' ) ) return;
the_post_thumbnail('post-image');
}
// Display featured image after title on the static pages in Genesis themes
add_action( 'genesis_entry_content', 'featured_post_image', 8 );

Add Featured Image on both Static Pages & Single Posts:

If you wanna show the featured image on both then you can use following code:

Featured Image Before Title:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
if ( ! is_singular( ) ) return;
the_post_thumbnail('post-image');
}
// Display featured image before title on both static pages and single posts in Genesis themes
add_action( 'genesis_entry_header', 'featured_post_image', 8 );

Featured Image After Title:

<?php
//* Do NOT include the opening php tag
function featured_post_image() {
if ( ! is_singular( ) ) return;
the_post_thumbnail('post-image');
}
// Display featured image below title on both static pages and single posts in Genesis themes
add_action( 'genesis_entry_content', 'featured_post_image', 8 );

Hence, you all set by displaying the images by positioning them. All the above codes are tested and outperformed very well. If you have any queries, feel free to ask in the comment section below.

See also

LEAVE A REPLY

Please enter your comment!
Please enter your name here