Last active
December 28, 2015 00:09
-
-
Save kadavre/7411456 to your computer and use it in GitHub Desktop.
Sometimes, you may want to add a cool drop down menu that will show all existing categories in your WordPress site. Here is a simple way of doing it. Copy and paste the code below into the index.php or sidebar.php file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="<?php bloginfo('url'); ?>/" method="get"> | |
<?php | |
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0'); | |
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); | |
echo $select; | |
?> | |
<noscript><input type="submit" value="View" /></noscript> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment