Support

Account

Home Forums ACF PRO Exclude Relationship Field Posts from Custom Query Reply To: Exclude Relationship Field Posts from Custom Query

  • 
    // this array_merge will fail if any of the fields do not have selections
    // this is quick to show an example
    // each field should be gotten separately
    // checked and merged if it is not empty
    $selected_posts = array_merge(
        get_field('selecciona_post_hero', false, false),
        get_field('selecciona_posts_destacados_1', false, false),
        get_field('selecciona_posts_destacados_2', false, false),
        get_field('selecciona_posts_destacados_3', false, false));
    $query_args = array(
      'post_type' => 'post',
      'posts_per_page' => 2,
      'paged' => $paged,
      'post__not_in' => $selected_posts
    );