Support

Account

Home Forums ACF PRO Can't list custom taxonomy in a Custom location rule

Solving

Can't list custom taxonomy in a Custom location rule

  • Hi guys,

    I am using this documentation to create a custom rule for a custom taxonomy.

    I had the rule working with categories (get_categories()), but as soon as I tried to list the custom taxonomy terms it no longer works.

    This issue is specifically for the rule values section of the code:

    add_filter('acf/location/rule_values/category', 'acf_location_rules_values_category');
    function acf_location_rules_values_category( $choices )
    {
    
        $terms = get_terms('ranges');
    
        if( $terms )
        {
            foreach( $terms as $term )
            {
                $choices[ $term->term_id ] = $term->name;
            }
        }
        return $choices;
    }

    If I use the foreach loop on a page with an echo, it lists the taxonomy terms perfectly but for some reason is not outputting the values in the ACF admin, you just get an empty drop down.

  • This is a bug with the latest version of ACF PRO and it’s also being discussed in this thread > http://support.advancedcustomfields.com/forums/topic/5-2-0-breaks-taxonomy-term-rules/

    Hopefully it’s fixed soon!

  • Thanks for your reply! I have actually already been on that thread yesterday with similar issue, and have already installed an earlier version of ACF pro. I guess it could still be a bug with the earlier version, but I have a feeling it’s probably my code that’s wrong.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Can't list custom taxonomy in a Custom location rule’ is closed to new replies.