[resolved] Featured image as a full size background in div element (3 posts)

  1. hrrubin
    Posted 2 years ago #

    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: http://rubinreklame.dk/design-til-folket/

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

    <div id="featuredimage">
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
    <img src="<?php echo $url; ?>" longdesc="URL_2" alt="Text_2" />
    <?php ?>
  2. Michael
    Forum Moderator
    Posted 2 years ago #

    the code seems to be working in my local test site.

    does that page have a featured image defined?

  3. hrrubin
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic