Home › Forums › Calendar Products › Events Calendar PRO › Featured Image not displaying in theme header
- This topic has 4 replies, 2 voices, and was last updated 10 years, 10 months ago by
George.
-
AuthorPosts
-
June 17, 2015 at 7:26 am #970035
Gareth
ParticipantOur theme uses featured images (when set) in the header as large banner images by calling “the_post_thumbnail” with custom sizes:
if ( has_post_thumbnail() ) { if ( is_mobile() ) { the_post_thumbnail('headerpic_mobile'); } else { the_post_thumbnail('headerpic'); } }But any Events Calendar featured images don’t display here. At the moment it only displays Events Calendar featured images in the events content section but this is below our header and navigation. This is the same with the default 2014 WP theme. Is this by design and is there a way round it?
I’ve edited a copy of the single-event.php template to remove the featured image from there where we don’t want it to display.
June 17, 2015 at 8:51 am #970102George
ParticipantHey Gareth,
I’m not sure why your theme wouldn’t pick up the featured image from events – the standard “thumbnail” is used for the events post type, not a funky or weird alternative, so in theory it should be picked up fine.
We don’t offer support for troubleshooting themes, technically, but I’m curious about what you would find by replacing the above instances of this:
the_post_thumbnail( 'headerpic_mobile' );With this:
echo get_the_post_thumbnail( get_the_ID(), 'headerpic_mobile' );Use the ‘headerpic’ and ‘headerpic_mobile’ sizes where appropriate there, and try this out. Let us know what you find!
Thanks,
GeorgeJune 17, 2015 at 10:55 am #970181Gareth
ParticipantThanks for your reply George. Unfortunately that code didn’t make a difference. I wonder if it’s because the featured image is called in the header.php which is too far removed from the events loop. Normal pages and standard posts show their featured images as expected just not events unless the featured image is called in single-event.php.
June 18, 2015 at 9:02 am #970959Gareth
ParticipantI did some hunting on displaying featured images outside the loop and managed to adapt some code into a working solution. Here’s my code snippet if it’s of help to anyone else:
$thumbID = get_post_thumbnail_id( get_queried_object_id() ); if ( has_post_thumbnail() ) { the_post_thumbnail( $picsize ); } else if($thumbID != '') { $bkgdImg = wp_get_attachment_image( $thumbID, $picsize ); echo $bkgdImg; } else { [fallback] }June 20, 2015 at 10:08 am #971634George
ParticipantThanks for sharing Gareth! Best of luck with your site.
-
AuthorPosts
- The topic ‘Featured Image not displaying in theme header’ is closed to new replies.
