Featured images in Genesis single posts and archives

If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

If you are building a child theme with Genesis, you may initially struggle with featured images in blog posts.

By default Genesis has a theme option relating to featured images in Archives. This can be found in dashboard>Genesis>Theme Settings ticking the boxes and setting the options will turn that on for you (ready for any CSS styling you need )

Genesis Theme Options

However, you will also want to display the featured image on the blog post.  Studio Press help is a bit crypitic but a small amount of code in your functions.php

sorts it all out. First define your custom image size, then add an action to display the image if it is a post. In this case I want to display an image 680×400  and align it centrally.

add_image_size( 'post-featured-image', 680, 400, TRUE );

add_action( 'genesis_entry_content', 'bw_show_featured_image_single_posts', 9 );
/**
* Display Featured Image in single Posts.
*
*/
function bw_show_featured_image_single_posts() {
    if ( ! is_singular( 'post' ) ) {
        return;
    }

    $image_args = array(
        'size' => 'post-featured-image',
        'attr' => array(
    '    class' => 'aligncenter',
        ),
     );

    genesis_image( $image_args );
}

 

Once again thanks to the great resource at http://sridharkatakam.com/how-to-display-featured-image-in-single-posts-in-genesis/ for the method

 


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *