WordPress.org

Support

Support » How-To and Troubleshooting » Display Header Image only if the current Page/Post has a Featured Image.

Display Header Image only if the current Page/Post has a Featured Image.

  • Sorry if this has already been covered in the forum.

    I have a question about controlling the display of featured images and header images.
    I’m using twentyeleven 3.5.1 (child)

    I assume I need an ‘ if ‘ statement in my header to display the Featured Image in the ‘Header Image’ area ONLY if the Page or Post has a featured image populated. By default WordPress will hide all featured images from the header image container on pages and posts if the “remove header option” is activated in the theme options. It would be ideal to be able to have this switched off, but also have the option to display featured images on pages and posts that have them.

    Any references would help a lot.. Thank You! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    @esmi

    Forum Moderator

    The Twenty Eleven theme allows you to control featured header images via the size of the image. If you upload a featured image that is 1000px wide by 288px high (or larger), it will be used as the header on that Post. If the image you have chosen is smaller than this, it will not be used as the header image.

    Yes, I understand that images must be at least 1000px by 288px to be displayed as the header on the post. But the issue is that I cannot use a featured image as the header when the default header image is removed from the Theme Options. If I want to have a featured image to display as a header, a default image must be activated in the Theme Options and then it displays on all pages that don’t have a featured image.

    Just want to show the Featured Image in the header area when the page or post has one set.

    Thank you for reply,,,,

    esmi

    @esmi

    Forum Moderator

    I cannot use a featured image as the header when the default header image is removed from the Theme Options

    Well, that would make sense. If I understand you correctly, you configured the theme to not show any header images via Appearance -> Header, yes? You can’t have it both ways. Either you configure the theme to show a header image – including featured images – or you don’t show any header images at all.

    If you want to change this behaviour, you would need to start modifying the theme (starting with header.php) using a child theme.

    Right… I’m looking for help with an ‘ if ‘ statement in the header.php that will echo the featured image if one exists. I thought this would be a common request but i’m not finding exactly what i’m looking for.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display Header Image only if the current Page/Post has a Featured Image.’ is closed to new replies.