I've created a TwentyEleven child theme. I want to use a featured image as a background in the page, inside <div id="primary">, using <style> tags. Inside header.php just before the closing </head> tag:
wp_head();
/* Get the featured image into the CSS
* Check if this is a post or page,
* and if it has a thumbnail.
if ( is_singular() && has_post_thumbnail( $post->ID )) : ?>
<style type="text/css">
#primary {
background: url("<?php
echo get_post_meta($post->ID, 'thumb', true);
?>") no-repeat scroll right bottom #FFFFFF;
}
</style>
<?php endif; ?>
</head>
The image does not display, but if I replace the get_post_meta() call with an actual url, it does. In other words, the get_post_meta() returns null or empty, and is confirmed with Firebug. It gets past the if() and the following is echoed into the html page source:
<style>
#primary {
background: url("") no-repeat scroll right bottom #FFFFFF;
}
</style>
What am I missing here?
Denis