WP Category Dropdown
WP Category dropdown plugin is a simple plugin that displays the parent and child categories in a dropdown. You can use a shortcode or a block to display the dropdown on a page or you can use the widget to display the dropdown on a sidebar.
Using the Shortcode
[wpcd_child_categories_dropdown] is the shortcode that can be used. This shortcode accepts the following parameters similar to wp_dropdown_categories. The options shown here are the default options.
‘orderby’ => ‘name’, // other options: date, modified, menu_order, rand
‘order’ => ‘ASC’, // can also use DESC
‘showcount’ => 0, // or 1 – this option shows/hides the number of posts in each category
‘hierarchical’ => 1,
‘hide_empty’ => 1, //can be 0 – this option will show/hide the categories without any posts
‘exclude’ => ”, //category or taxonomy term id’s
‘include’ => ”, //category or taxonomy term id’s
‘default_option_text’ => ‘Parent Category’,
‘default_option_sub’ => ‘Child Category’,
‘category’ => ‘category’ // or any custom taxonomy
The default_option_text is the text that will show up as the first option in the dropdown. The default_option_sub will show up as the first option for the child category dropdown.
When using the shortcode, category can be any custom taxonomy.
Adding the Dropdown with the Widget
You can also use the widget to display the dropdown on the sidebar which gives you a bunch of options to choose from.
A quick demo of the plugin on the frontend
Using the Gutenberg Block
The plugin now offers the option to add the parent and child category dropdowns using the block editor. You can find the block under the widgets category.
The block gives you the options to order the categories, select a taxonomy, include or exclude categories etc. Below is a demo of the WP Category Dropdown block.