Home › Forums › General Issues › the_image not returning value in media attachments › Reply To: the_image not returning value in media attachments
Hey Elliot,
Thanks for the prompt reply. This is just a function I’m running that pulls a field from the image/attachment meta. So it would be the page.php template, I suppose. This is a genesis child theme, too, if that helps.
In the function I didn’t declare the global $post variable originally, but I did just now and it didn’t seem to change anything. I tried getting the field using the_field() method and also as a variable and neither seemed to work.
Here’s teh function in full, don’t mind the ugly code. =)
add_action( 'genesis_before_loop', 'ds_add_featured_image', 1 );
function ds_add_featured_image() {
global $post;
$variable = get_field('featured_image_link');
?>
<div class="featured-image">
<a href="<?php get_field( $variable ); ?>" title=""><?php the_post_thumbnail(); ?></a>
<span class="caption"><?php get_post( get_post_thumbnail_id() )->post_excerpt;?> </span>
</div>
<?php }
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.