Featured image background
-
I have this in my page template. The problem is that the css class is not applied to the div. The html code has the div css class, but in Chrome developer tools there is no class applied.
<?php if (has_post_thumbnail( $post->ID ) ): $featimg = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); else: $featimg = wp_get_attachment_image_src( 1731, 'full', false ); endif; ?> <div class"featured-header" style="background-image: url('<?php echo $featimg['0']; ?>')"> <?php the_title( '<h1 class="entry-title-white">', '</h1>' ); ?> </div>
I have also tried this, which output exactly the same as the above.
<?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $featimg = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $featimg = $featimg[0]; ?> <?php else: $featimg = get_bloginfo( 'stylesheet_directory') . '/images/featured-default.jpg'; ?> <?php endif; ?> <div class"featured-header" style="background-image: url('<?php echo $featimg; ?>')"> <?php the_title( '<h1 class="entry-title-white">', '</h1>' ); ?> </div>
I’m stumped. Help desperately needed.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Featured image background’ is closed to new replies.