Home Forums General Issues Taxonomy field type: filter to only show parents


Taxonomy field type: filter to only show parents

    • Anu

    • September 13, 2013 at 12:53 am

    Is there an easy way to filter a taxonomy field type to only show the top level parent terms?

    • Elliot

    • September 14, 2013 at 1:26 pm

    Hi @digitalquery

    Currently, there is no filter for the wp_list_categories args within the taxonomy field.

    You can edit the core/fields/taxonomy field to add on in, however this may be removed after updating.

    I’ll add this to the to-do and add it into the core.


    • Elliot

    • September 17, 2013 at 4:50 pm

    Hi @digitalquery

    Good news. I have just added and pushed to github an update for the taxonomy field.
    This update contains a new filter allwoing you to customize the args used in the wp_list_categories function.

    You can use it like so:

    add_filter('acf/fields/taxonomy/wp_list_categories', 'my_taxonomy_args', 10, 2);
    function my_taxonomy_args( $args, $field )
        // do stuff to $args
        return $args;
    • Anu

    • September 17, 2013 at 7:37 pm

    🙂 fantastic, will test this out in the next couple of days, thanks

    • Anu

    • September 25, 2013 at 8:26 pm

    Hey, just wanted to let you know that this works great – was able to add this line:

    $args['depth'] = 1;

    to the filter function and only show the top level taxonomy terms in the edit screen

    • charlie

    • October 1, 2013 at 9:24 pm

    Great. I got it working too.

    Is there a way this can be applied only to 1 specific taxonomy field? I have a filter that’s useful for one taxonomy field but not something I’d want to apply to all my taxonomy fields.

    I tried in my add_filter function using ‘acf/fields/taxonomy/wp_list_categories/name=XYZ’ but that didn’t work (the field just displayed all the categories)

    Alternatively I just might not be understanding this correctly.


    • Elliot

    • October 11, 2013 at 12:33 pm

    Hi @charlie

    Answer provided on

    Compare $field[‘name’]

    • socki03

    • October 23, 2013 at 7:39 am

    I updated taxonomy.php from the github version after finding out that 4.2.2 doesn’t include the $args array & application of filters. Will this be released in the next update? I’m just curious to make sure that this still works after the next ( or future ) updates. Thanks!

    • Elliot

    • October 23, 2013 at 5:37 pm

    Hi @socki03


    • socki03

    • October 24, 2013 at 1:12 am

    @elliot Awesome. Thanks!!

    Also, I have to say that I love this plugin, it makes WordPress SO. MUCH. BETTER.

    Thanks again for all your work!

  • This solution Still works in Feb 2015.

    Great plugin!

  • This solution doesn’t work if you choose select type, only work’s for checkboxes. How can use this for dropdown select ?

  • @faticesko Me too, only work for checkboxes or radio buttons.

  • For Select or Multiselect dropdown use the below code to query only parents.

    function hide_child_taxonomies( $args, $field ) {
        if( 'YOUR_FIELD_NAME' === $field['_name'] ) {
            $args['parent'] = 0;
        return $args;
    add_filter('acf/fields/taxonomy/query', 'hide_child_taxonomies', 10, 3);
Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.