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
- Can’t custom taxonomies have same terms (slugs) as categories?
- get_categories for custom post type with a specific custom taxonomy attached
- Order get_terms() By Custom Field
- How can I add the featured image functionality to a custom taxonomy?
- Combine two taxonomies in a hierarchical tree
- Use tag interface for hierarchical taxonomy?
- How can I select a primary category?
- Using URL parameters, list posts from category and custom taxonomy
- Dropdown with category selection
- Filter categories using tags
- How to make custom taxonomy check boxes like ‘Categories’
- Different templates for parent and children categories/taxonomies
- Make parent categories not selectable
- cat_is_ancestor_of() for custom taxonomies
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- How to create non-unique sub-category slugs?
- Show Post from parent category (custom taxonomy) ONLY!
- Saving two categories from two dropdowns in front end posting form
- How to convert regular categories to custom taxonomy?
- How can I display parent and child taxonomies in separate drop downs?
- Filter get_categories() for taxonomy term in WordPress
- How to get next previous category in same taxonomy?
- Get id of category from drop down menu
- How to add HTML5 ‘required’ attribute to wp_dropdown_categories() without JavaScripts?
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Add custom category name as data-filter to switch between these categories
- Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?
- Getting WordPress custom taxonomy/category?
- Are Custom Taxonomy Templates Possible?
- Display empty taxonomy terms with get_terms()
- Get a list of Terms for a specific category
- Order Taxonomy Term by date created
- How to display a description of a given category from a custom taxonomy
- How to get the number of child categories a specific parent category has?
- Can paginate_links() be customized for a specific category or tag?
- Filtering by Category doesnt paginate correctly on the backend
- How to retain the values from dropdown category lists after wrong form submission?
- Dropdown category filter
- How can I convert some categories to a custom taxonomy?
- Help with multiple dropdown tags search
- Category tree is flattened inside admin upon saving
- Make parent category not selectable when it has child categories
- Replace category titles
- Get multidimensional array that reflects category hierarchy
- PHP Fatal error: Cannot use object of type WP_REST_Response as array in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- Hide posts of a certain category unless logged in
- If statement within PHP echo
- How to know if it’s a child taxonomy?
- 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 provide value for ‘selected’ on wp_dropdown_categories() for ‘multiple’ options
- 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
- Filter Home Page Posts in Buddypress [closed]
- Categorising posts/pages into years published
- Should the actual /category/ directory be 404? Is that normal WP behaviour
- Limit number of terms that a custom taxonomy can save per custom post type
- Inserting Category programmatically
- 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?
- Additional form options based on category selected not working
- category filter doesn’t work in WPML
- Query posts from category based on a filter most favorited
- Categories of custom taxonomy don’t show any posts
- One Specific Category To Permalink
- Filter Categories in meta box for CPTs
- add_rewrite_endpoint returns 404 on archives
- Get parent and children taxonomy in different dropbox
- Show only first category name in RSS?
- Custom sub taxonomy order by
- Add category only if post has custom taxonomy category
- wp_dropdown_categories() scripts working erratically on sidebar
- Filter $cpt categories to omit certain category
- Categories overview that links to page displaying posts
- How to set a filter by category within a customised page
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Get all media categories
- Add child category to parent on post creation and save
- Refine/Filter the Search Results by Category
- Get Number of total Parent Categories for Custom Taxonomy
- Admin comments and user restrictions
- WordPress Post # of # filtered by category slug
- Pagination for ajax category filter
- Get posts from specific taxonomy term
- ajax for filtering posts by category in wordpress loops
- How to hide category name
- How to use an array of categories as a dropdown?
- Display custom taxonomy attached to the post on post single page
- Why custom taxomony not showing when create a post?
- Limit categories and it’s subcategories for specific group of users