dpuk44 Posted July 11, 2015 Share Posted July 11, 2015 I cant work this one out for the life of me. The following code works great on my page.php, but cant get the same result on home.php <!-- Main component for a primary marketing message or call to action --> <?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <div class="jumbotron" style="background-image: url('<?php echo $feat_image; ?>');"> <div class="banner-box"><h1><?php $meta_value = get_post_meta( get_the_ID(), 'meta-text', true ); echo $meta_value; ?></h1></div> </div> Anyone? Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 11, 2015 Share Posted July 11, 2015 What does "not work" mean? Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 11, 2015 Share Posted July 11, 2015 Have you done a viewsource on the page after it loads to see what/if anything is being populated in the url tag in the div style? To see if it's empty or the path is wrong. 1 Quote Link to comment Share on other sites More sharing options...
dpuk44 Posted July 12, 2015 Author Share Posted July 12, 2015 Hi, I have checked the source code and I can see the below. The URL seems empty as does the banner-box div which should pull in the data from the metabox. <div class="jumbotron" style="background-image: url('');"> <div class="banner-box"><h1></h1></div> </div> Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 13, 2015 Share Posted July 13, 2015 Have you checked to see of $post->ID contains a value? How about get_the_ID(); does it return a value? Note that get_the_ID() needs to be called within The Loop. More information can be found here: https://codex.wordpress.org/Function_Reference/get_the_ID Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.