• Resolved hrrubin

    (@hrrubin)


    In the page.php I’m trying to add a div after the header. Inside this div I want the post’s featured image as a full size background-image.

    I’ve been looking at various threads, but while some were resolved, I couldn’t make it work.

    This and this.

    My webpage: https://rubinreklame.dk/design-til-folket/

    Below is some code, where I at least get something online (the alt-text).

    <div id="featuredimage">
    <?php
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
    <img src="<?php echo $url; ?>" longdesc="URL_2" alt="Text_2" />
    <?php ?>
    </div>
    #featuredimage{
    width:100%;
    height:600px;
    overflow:hidden;}
Viewing 2 replies - 1 through 2 (of 2 total)
  • the code seems to be working in my local test site.

    does that page have a featured image defined?

    Thread Starter hrrubin

    (@hrrubin)

    That was just the thing. I thought it was enough that some post had one, but I mixed the things up. It is, of course working just fine ??

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Featured image as a full size background in div element’ is closed to new replies.