Categories
Plugins Web Development WordPress

WordPress Parent and child categories using Ajax

Updated: 4/26/2019

wp_dropdown_categories displays the WordPress categories in a nice drop down. You can choose to display the parent and child categories in a hierarchy. Using Ajax, it is simple to display the child categories based on the selected parent category.

I wrote the WP Category Dropdown plugin to make it easy to add this dropdown to a page or the sidebar. The plugin gives you a shortcode that will let you display all the categories in a dropdown. You can select the parent category and the child categories for that parent will be displayed in another dropdown.

This feature will come in handy when you want to give your users an option to navigate easily through the number of categories you have on your site. The shortcode gives you the option to display categories from a custom post type.

The plugin can differentiate between the categories that do and do not have child categories. If the selected parent category has a child, then you will see another drop down with the list of child categories, otherwise, you will be automatically redirected to the selected category page.

The shortcode gives you an option to display only the categories with children and if there only a few categories without children, you can use “exclude” to hide these categories from the drop down.

The plugin also has an option to add a widget to the sidebar to display the dropdown categories.

The plugin can be downloaded from the WordPress plugins page – https://wordpress.org/plugins/wp-category-dropdown/. Plugin documentation is available here.

Here is a quick demo of the how the plugin works.

Leave a Reply