Support

Account

Home Forums General Issues Query cpt then echo if relationship exists Reply To: Query cpt then echo if relationship exists

  • You forgot to set the postdata in foreach loop.
    Just add this after the foreach line: setup_postdata($addon);

    Here is the doc: https://developer.wordpress.org/reference/functions/setup_postdata/

    That will set the $addon as the main $post for every iteration in foreach loop.

    As an alternative solution, you could also add the needed post_id in ACF’s get_field method like this:
    get_field(‘add_ons_suites’, $addon->ID)

    That will bring the acf field data for that specific post