Created
November 22, 2017 22:57
-
-
Save celticwebdesign/db5480ea8fc8af11e64104ffbc9bef17 to your computer and use it in GitHub Desktop.
Gets a list of Category terms and make a linkable form select,
This file contains hidden or 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
<select name="cat" onChange="window.document.location.href=this.options[this.selectedIndex].value;"> | |
<?php | |
$args = array( | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => 1, | |
); | |
$categories = get_categories($args); | |
foreach ( $categories as $category ) { | |
$term_link = get_category_link($category->term_id ); | |
$term_link = esc_url( $term_link ); | |
echo '<option value="'.$term_link.'">'.$category->cat_name.'</option>'; | |
} | |
?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment