Taxonomy field type: filter to only show parents

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

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

    • 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.


      • 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;
      • :) fantastic, will test this out in the next couple of days, thanks

        • 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.


            • 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!

                • 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!

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

                    You must be logged in to reply to this topic.