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

  • This works (for me)

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