Just from skimming your code, it actually pretty much does the same as the WordPress API function wp_dropdown_categories()
. It isn’t as sophisticated though, no insult intended. Because wp_dropdown_categories()
is capable of displaying deeper leveled hierarchies – correctly – then your own function, I can’t see a reason for not just using wp_dropdown_categories()
for your purpose. If there is a reason, that I have overlooked or just can’t see, then you should take a look at the source of wp_dropdown_categories()
to get some inspiration and/or guidance from it.
Related Posts:
- wp_dropdown_categories and custom taxonomy + custom post type
- How to organize custom categories for filtering and selecting
- How to fix select filter on category
- Dropdown switching subcategories portfolio
- Combine two taxonomies in a hierarchical tree
- Use tag interface for hierarchical taxonomy?
- How can I select a primary category?
- Different templates for parent and children categories/taxonomies
- Make parent categories not selectable
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- How to convert regular categories to custom taxonomy?
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Getting WordPress custom taxonomy/category?
- Display empty taxonomy terms with get_terms()
- Order Taxonomy Term by date created
- How to get the number of child categories a specific parent category has?
- Can paginate_links() be customized for a specific category or tag?
- How to retain the values from dropdown category lists after wrong form submission?
- Make parent category not selectable when it has child categories
- Get multidimensional array that reflects category hierarchy
- Hide posts of a certain category unless logged in
- If statement within PHP echo
- How to use wp_category_checklist()?
- Taxonomies for WordPress Media Library [duplicate]
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- How to Filter categories in the permalink structure
- How to display posts under a specific subcategory of a given category
- Specifying multiple categories in URL (permalink)?
- Taxonomy filter all children
- Categorising posts/pages into years published
- Can you pre-check wordpress categories?
- Change existing taxonomy settings when using custom taxonomy
- Automatically set default password to all posts in a specific category
- get_the_categories filter returns an empty array
- How to get the id from the custom category?
- Query posts from category based on a filter most favorited
- Categories of custom taxonomy don’t show any posts
- Get parent and children taxonomy in different dropbox
- Custom sub taxonomy order by
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Get all media categories
- Refine/Filter the Search Results by Category
- Pagination for ajax category filter
- Get posts from specific taxonomy term
- How to hide category name
- Why custom taxomony not showing when create a post?
- How do I display only two categories Instead of displaying all categories
- Dropdown Categories used in form shows no results when all is selected
- How to make the ‘delete’ button inactive on some categories?
- Get Categories Where Taxonomy Equals ‘n’
- Display all product tags associated with a specific product category
- custom page for custom Taxonomy
- Custom page category taxonomy 404
- How to hide some categories in dashboard
- Change post title if post has specific category
- Is it possible to create an alias/custom taxonomy for a category name?
- Same menu for different taxonomies to reach different content
- Showing HTML if Post is In Certain Taxonomy Term
- I need to exclude from a query a category and a few custom taxonomies
- Category link redirect to custom template page instead of index.php?
- How can I filter posts by tag on the fly
- How could I write a get_categories_by_year() function?
- Assign a custom post to a custom taxonomy based on custom field value
- wp_dropdown_categories initial value
- Custom Fields Value As Taxonomy
- How to get posts using category slug in ClassiPress?
- Exclude category from drop down list form
- Exclude posts without category from loop
- List taxonomy terms assigned to a post in hierarchical view
- Page category filter in admin dashboard
- How to filter tags by category?
- Automatically add custom taxonomy to posts in a category
- How to set the same base url for two different taxonomies?
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- Get WooCommerce product category list in functions.php
- How can i echo next and previous custom category from a Taxonomy
- Correct Hook/Filter to amend category choices on post edit page
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- How to add custom option to wp_dropdown_categories?
- Using heirarchial tags or Custom taxonomies
- Renaming default category taxonomy?
- custom browse by
- Most efficient way to display current post subcategories?
- Dynamically creating content on custom URL without getting 404
- ACF Gallery with Media Categories – how do display categories and sort
- Display List of Categories Within a Custom Taxonomy
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- New Category – custom taxonomy
- How to add a post with new Taxonomy without assigning to default category?
- How to add additional field to Add new category part (without plugin use) [closed]
- add custom option to get_categories dropdown
- List Terms by category
- How to create default categories in new installs?
- Taxonomy for custom post type not found
- Check if value is a custom taxonomy category name
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Form Value of drop down category + Translation of ‘show option none’
- How to create a photo gallery that can be filtered by the image categories
- Replace category titles inside RSS feed