Support

Account

Home Forums ACF PRO Show only categories in the relationship field taxonomy filter Reply To: Show only categories in the relationship field taxonomy filter

  • Something like this :

    function load_recipe_category_filter( $field ) {
        
        $terms = get_terms( array(
            'taxonomy' => 'recipe_category',
            'hide_empty' => false
        ) );
        if ( !empty($terms) ) {
            foreach( $terms as $term ) {
                $field['taxonomy'][] = 'recipe_category:'.$term->slug;
            }
        }
    
        return $field;
    }
    
    add_filter('acf/load_field/key=field_5899e67cc9f5fff', 'load_recipe_category_filter');