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(); ?>
AND
<?php endwhile; // end of the loop. ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.