Home › Forums › General Issues › Post object with conditions performance, elsif or switch or separate blocks › Reply To: Post object with conditions performance, elsif or switch or separate blocks
If I would for some reasons convert to relationship can I still use get_field without post_object->ID? As I prefer get_field queries to structure the quries before echo them over the_field directly into the echo.
Just having a quick look at https://www.advancedcustomfields.com/resources/relationship/ where the_field is used once using setup_postdata();
. Just did a quick test but even if I setup setup_postdata();
I need to call
within the foreach loop:
$imageArray_BG = get_field('post_hero_img_1', $post_object->ID); // Array returned by Advanced Custom Fields
$imageAlt_BG = esc_attr($imageArray_BG['alt']); // Grab, from the array, the 'alt'
$imageURL_BG = esc_url($imageArray_BG['url']); // Grab the full size version
Which means all posts in the relationship is not passed in one query, correct?
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.