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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.