0

I am using the ACF purely so the user can upload images to a predefined location and have assigned the page rules accordingly. Everything seems to be fine on the WP back-end, with the three images uploaded to the fields. However, on the font end, nothing apart from blank box is appearing at all where the images should be. Looking at the source that WP is outputting, there is only blank code:

<img src="" class="middle" alt="image1"/>

This is the loop I am using:

<?php query_posts("posts_per_page=1&post_type=page&page_id=168"); if (have_posts()) :  
while ( have_posts() ) :   
  the_post(); ?>
 <!--If you want to refer to the child of parent page, use "post_parent=" -->
 <li>
  <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    <img src="<?php the_field('image_1'); ?>" class="middle" alt="image1"/>
  <a href="<?php the_permalink(); ?>" class="button">View More</a>
 </li>
  <?php endwhile; ?>
          <!-- post navigation -->
        <?php else: ?>
          <!-- no posts found -->
        <?php endif; ?>
        <?php wp_reset_query(); ?>

It is important to note that I am not pulling the images from another page. I just want the images to relate to the template & page I am working on.

2
  • it is apparently a problem with the_field(), what is the_field() and how did you write this funtion??? Commented Dec 5, 2011 at 12:03
  • Have you used this plugin before? the_field is standard. Commented Dec 5, 2011 at 12:14

3 Answers 3

1

Make sure the image field is outputting the id or url of the image link.

    <?php if(get_field('YOUR FIELD NAME')): while(has_sub_field('YOUR FIELD NAME')): ?>
        <img class="logo" src="<?php the_sub_field('image_1'); ?>" />
    <?php endwhile; endif; ?>
Sign up to request clarification or add additional context in comments.

Comments

0

I just needed to nominate the home page id the function:

<img src="<?php the_field('image_2', '245'); ?>" class="middle" alt="image2"/>

Comments

0

you can use get_the_field() to get the right value of the field,

<img src="<?php get_the_field('image_1'); ?>" class="middle" alt="image1"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.