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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.