How to display Featured Image in a single post in Genesis Framework

Tag: |   Category:

If you are using Genesis Framework you will notice that Featured Image is displayed only on the Blog post, and not showing in single post. If you want to display Featured Image on single post (full article page) insert blow snippets to your theme’s functions.php file

1. Display Featured Image after Title

//* Display featured image after single post title
add_action( 'genesis_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
 if ( !is_singular( array( 'post', 'page' ) )) return;
 the_post_thumbnail('large'); //you can use medium, large or a custom size
}

2. Display Featured Image before Title in Posts and Pages

How to display featured image before Posts title in Genesis

// Register a custom image size for Singular Featured images
add_image_size( 'singular-featured-thumb', 800, 250, true );

add_action( 'genesis_before_entry', 'sk_display_featured_image' );
function sk_display_featured_image() {
	if ( ! is_singular( array( 'post', 'page' ) ) ) {
		return;
	}
	if ( ! has_post_thumbnail() ) {
		return;
	}
	// Display featured image above content
	echo '<div class="singular-featured-image">';
		genesis_image( array( 'size' => 'singular-featured-large' ) );
	echo '</div>';
}

3. Display Featured Image before Title in Archive page

// Move titles 
add_action( 'genesis_meta', 'move_title_below' );
function move_title_below() {
     if (is_home() || is_archive()) {
     remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
      add_action( 'genesis_entry_header', 'genesis_do_post_image', 3 );
}
}
Copyright © 2024 Siam Naulak.
magnifiercrossmenu