Change Category List in Form to dropdown
-
Hi there!
My users are allowed to post from the frontend. Everything is running fine; but not really good. My Site have about 100 categorys. So if somebody opens the “Add Post” Frontend Site he gets a damn long list with the tags and have to scroll his way down. This is very annoying, so i wanted to invest time in this go change the long list into a dropdown one.
My research (i am a bloody beginner) was leading me to this part of the code which seems to do the category-list.
I am using Front-end Post & Media Manager from WP-Eden; but I got never a answer from the developer:/
` <!– Categories –>
<li style=”<?php if(!in_array(‘category’, $taxonomies)) {echo “display:none;” ;} ?>”>
<div class=”panel panel-default”>
<div class=”panel-heading”><b><?php _e(‘Categories’,’postbyuser’); ?></b></div>
<div class=”panel-body”><ul>
<?php
if(!empty($thispost->ID)) {
$categories = get_the_category($thispost->ID);
foreach ($categories as $c) {
$selected[] = $c->cat_ID;
}
}else {
$selected[] = NULL;
}include_once(ABSPATH . “/wp-admin/includes/template.php”);
wp_category_checklist(0, 0, $selected);
?>
</ul>
</div>
</div>
`
How could I archieve my goal? It would be very kind if someone could poke me in the right direction!Thank you very much!
-
Edit: I managed to get a dropdown, so i am on the half way. I replaced “wp_category_checklist(0, 0, $selected);” with “wp_dropdown_categories(‘orderby=ID&order=ASC&hierarchical=1’);” . But when i choose a option from it i directs me to the category page.
- The topic ‘Change Category List in Form to dropdown’ is closed to new replies.