I am customizing a plugin. I needed it to show a list of the categories in hierarchy, which I got working with all of the functions of the plugin. I'm using wp_dropdown_categories
, but I'd like to display the list of categories as their slugs, and not as their category names. Any suggestions?
Here's what I have so far:
function replace_id_for_slug( $option ) {
$categories = get_categories( "hide_empty=0" );
preg_match( '/value="(\d*)"/', $option[0], $matches );
$id = $matches[1];
$selectID = $nextItem;
$slug = get_cat_slug( $id );
foreach ( $categories as $category ) {
if ( $category->cat_ID == $id ) {
}
}
return preg_replace( "/value=\"(\d*)\"/", "value=\"$slug\"", $option[0] );
}
$select = wp_dropdown_categories(
"hierarchical=1&hide_empty=0&echo=0&name=field_$nextItem&id=$selectID&class=categoriesBox"
);
echo $select;
I forgot to mention that this is for the admin backend. I've tried playing around with the walker class, but I am at a loss. Do you know of any other way this could be accomplished?
$nextItem
come from?