Support » Themes and Templates » TwentyEleven Mod – Using featured image in css

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi


    Forum Moderator

    Are you saving the featured image url in a custom field called “thumb”.



    I’m using the featured image feature within TwentyEleven, I’ll check the DB and see what it’s called there…



    Thanks esmi, you got it – “thumb” doesn’t exist in postmeta table. (I lifted the code directly out of the get_post_meta() example in the codex – I won’t do that again!)

    Here’s the working solution:

    if ( is_singular() && has_post_thumbnail( $post->ID )) :
       $thumb_id = get_post_meta($post->ID, '_thumbnail_id', true);
       $thumb_url = wp_get_attachment_url($thumb_id); ?>
    <style type="text/css">
    #primary { background: url("<?php echo $thumb_url ;?>") no-repeat scroll right bottom #FFFFFF; }
    <?php endif;

    Hey superpotion,

    Do you add this code into the page.php file? Or the functions.php file? Sorry for the confusion.

    Thanks in advance,


    @blaze – the code is in header.php of the child theme.



    Thanks for clearing that up! 😀


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘TwentyEleven Mod – Using featured image in css’ is closed to new replies.