Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/297262-featured-image-not-showing-on-homephp/
Share on other sites

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>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.