Support

Account

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?