Add featured image to page, after header

Community Forums Forums Design Tips and Tricks Add featured image to page, after header

This topic is: not resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Jon Bellah 1 year, 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12031

    fireflyloft
    Participant
    Post count: 1

    I am working on my first custom theme. I would like to add the featured image to each page so that it displays under the header but before the content/sidebar. I am having trouble figuring out how to get the featured image to show up on the pages. Can anyone help?

    Thanks!!

    #12045

    Jon Bellah
    Participant
    Post count: 109

    Add this to your functions.php file:

    [php]
    add_action(‘genesis_after_header’, ‘child_custom_images’);
    function child_custom_images() { ?>
    <!– Add your HTML here –>
    <?php }
    [/php]


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    #12047

    Darren
    Participant
    Post count: 14

    Hi John – thanks for code. Will this also work on getting the featured image to display on blog posts?

    #12049

    Jon Bellah
    Participant
    Post count: 109

    Ah, I misread the original question, actually. The code above is to display a presumably static image. In order to add a featured image below the header to blog pages, the code would look like:

    [php]
    add_action(‘genesis_after_header’, ‘child_custom_images’);
    function child_custom_images() {
    if (is_single()) { ?>
    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail();
    } ?>
    <?php }}
    [/php]

    This code will only display on post pages, and will check to see if the post has a thumbnail (featured image) assigned to it. If it does, it will display it. If it does not, it will not display anything.


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    #12050

    fireflyloft
    Participant
    Post count: 1

    Whoo hoo!! Thanks so much for your help. :)

    #12051

    Jon Bellah
    Participant
    Post count: 109

    No problem! Glad I could help. :)


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.