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');
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.