Home Forums Front-end Issues Querying with ACF relationship values Reply To: Querying with ACF relationship values

  • I was just looking over the original code that you posted and it contains some serious errors and logic flow issues.

    For example, near to top at about line 7 there is:

    <h2 class="doctor-title"><?php echo get_the_title(); ?></h2>

    This should appear inside the main loop that is displaying the current post, however the main loop does not happen until deep into the code for this template at this line.

    <?php while ( have_posts() ) : the_post(); ?>

    This also means that most all of the get_field() statements that exist before the main WP loop starts should be returning nothing or erroneous data.

    My suggestion would be to remove all the ACF and extra coding for displaying custom field and data and to first get the template code correct to get the post that’s supposed to be displayed in order. Then once that’s done to start adding in extra data.

    Basically, except for any wrapper elements, everything for displaying this post should fall between.

    <?php while ( have_posts() ) : the_post(); ?>


    <?php endwhile; // end of the loop. ?>