I'm using the below code in my header.php file to have a different div depending on the page:
<?php
if ( is_singular( 'movie' ) ) {
echo "<div class='heroImagePage' style='background-image:url(blur.jpg);'>";
} elseif (has_post_thumbnail( $post->ID ) ) {
echo "<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> <div class='heroImage' style='background-image:url(<?php echo $image[0]; ?>);'>";
} else {
echo "<div class='heroImagePage' style='background-image:url(blur.jpg);'>";
}
?>
The conditions for if ( is_singular( 'movie' ) ) { and else { work fine, but the one that checks if there's a featured image doesn't. The code in there is to get the URL of the featured image so it can insert it as the div's background image. I think the issue is the echo inside an echo?
When I look at the code it outputs in my browser, it looks like this:
<div class="heroImage" style="background-image:url(<?php echo ; ?>);">
I've tried and looked online to help fix it, but can't seem to find a solution. Appreciate any help.
Aucun commentaire:
Enregistrer un commentaire