Support

Account

Home Forums General Issues Filter Relationship query of 2 different post type Reply To: Filter Relationship query of 2 different post type

  • The answer by @jarvis is a good solution. There is another option that is slightly more complicated. You can use an acf/fields/relationship/query filter.

    Somewhere in your functions.php file add

    
    function acf_relationship_only_struttura($args) {
      $args['post_type'] = 'struttura';
      return $args;
    }
    

    Then just in your template where you want to show the field

    
    add_filter('acf/fields/relationship/query/name=relazioni_strutture', 'acf_relationship_only_struttura');
    $posts = get_field('relazioni_strutture');
    remove_filter('acf/fields/relationship/query/name=relazioni_strutture', 'acf_relationship_only_struttura');