I am trying to do two things, which I have no idea how to do:
give child categories the same class as the parent category (which is the parent category-slug)
create a menu which displays my categories, where the child categories will be displayed as dropdown-items when hovering the parent categor
Currently I am using this code to generate the classnames for my categories, and create my menu:
<?php
$args = array(
'hide_empty' => 0
);
$categories = get_categories($args);
$menu = '<ul class="nav">';
// iterate through your categories
foreach($categories as $category) {
$menu .= '<li class="' . 'cat-item category-' . $category->slug . '">' . '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">' . $category->cat_name . '</a>' . '</li>'
}
$menu .= '<li class="menu-border">' . '</li>' . '</ul>';
echo $menu;
?>