February 23, 201511 yr I'm trying to insert an ACF relationship field on the home page between two post loops. I can get the posts to display or the relationship field, but not both. Any help appreciated! <?php query_posts('showposts=1'); ?> <?php while ( have_posts() ) : the_post(); ?> .... <?php endwhile; // end of the loop. ?> <?php $posts = get_field('case_study_link'); if( $posts ): ?> <?php foreach( $posts as $p ): ?> <?php echo get_the_title( $p->ID ); ?> <img src="<?php the_field('main_image', $p->ID); ?>" /> <?php endforeach; ?> <?php endif; ?> <?php query_posts('showposts=1&offset=1'); ?> <?php while ( have_posts() ) : the_post(); ?> ... <?php endwhile; // end of the loop. ?>
February 23, 201511 yr You should reset the post data on your loops. Although i'm not sure why grabbing the posts and then just using a foreach would be affected by it... but it probably is. <?php // The Query query_posts( $args ); // The Loop while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; // Reset Query wp_reset_query(); ?> Edited February 23, 201511 yr by EpicWebs
Create an account or sign in to comment