Created
October 8, 2013 13:49
-
-
Save versluis/6884992 to your computer and use it in GitHub Desktop.
adding categories to P2
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
<select name="drop_cat" id="drop_cat"> | |
<option value=""><?php echo esc_attr(__('Select a Category', 'p2' )); ?></option> | |
<?php | |
$args = array ( | |
'type' => 'post', | |
'child_of' => 0, | |
'parent' => '', | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => 0, | |
'hierarchical' => 1, | |
'exclude' => '', | |
'include' => '', | |
'number' => '', | |
'taxonomy' => 'category', | |
'pad_counts' => false | |
); | |
$categories = get_categories($args); | |
foreach ($categories as $cat) { | |
$option = '<option value="'.$cat->category_nicename.'">'; | |
$option .= $cat->cat_name; | |
// show how many posts there are in each category | |
// $option .= ' ('.$cat->category_count.')'; | |
$option .= '</option>'; | |
echo $option; | |
} | |
?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment