Support

Account

Home Forums Front-end Issues Image not displaying

Helping

Image not displaying

  • Hi All,

    I’ve created a very simple image variable for a WordPress project:

    <div class="container blog_info">
     <?php
    	while(have_posts()) {
    		the_post();?>
    		<div class="post-item">
    			<div class="post-image"><img src="<?php echo $post_image ?>"></div>
    			<h2 class="blog_heading">
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			<?php the_excerpt(); ?>
    			<a class="btn-blog" href="<?php the_permalink(); ?>">More &raquo;</a>
    		</div>
    	<?php }
     ?>
    </div>

    For some reason the selected image does not display:

    <?php echo $post_image ?>
    <?php $post_image = get_field(“post_image”); ?>

    I’m obviously missing something! Thanks in advance 🙂

  • What is the return values setting of your image field?

    Is your code incomplete?

    To use what you are using the return value for your field needs to be set to URL

    
    <img src="<?php $post_image = get_field('post_image'); echo $post_image; ?>">
    

    or

    
    <img src="<?php the_field('post_image'); ?>">
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.