Home Forums General Issues Values not loading correctly in custom post type loop


Values not loading correctly in custom post type loop

  • I’m trying to add a custom post type loop to the footer of my website. The loop seems to be working correctly because it pulls in the custom post type content. But it is showing the same ACF values for each post. I can’t figure out how to get it to load the correct values for each post. I’ve tried passing in the post id and that didn’t help. Also, I’ve noticed that when I try to add a new field it doesn’t even show up in the loop at all (I used var_dump to see what fields were available).

    Please help!

    							$the_query = new WP_Query( array(
    							    'post_type' => 'location',
    							    'posts_per_page' => 3
    							if($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
    							$current_post_id = $post->ID;
    							<div class="location">
    								<div class="icon"></div>
    								<h3><?php the_title(); ?></h3>
    								<div class="address">
    									POST: <?php echo $current_post_id; ?>
    									<?php the_field('location_street'); ?><br />
    									<?php the_field('address_city'); ?>, <?php the_field('address_statthee'); ?> <?php the_field('address_zip'); ?><br />
    									<?php the_field('phone_number'); ?>
    								<a class="arrow-link" href="<?php the_permalink(); ?>"><?php the_field('location_btn_text'); ?><span></span></a>
    						<?php endwhile; wp_reset_query(); endif; ?>
  • I’ve looked at your code several times and I don’t see anyghing wrong with it.

    Where is this code located?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.