Hello I have a main menu in my website
Home | How to start | about | contact | categories
but I add one item that lists all categories in functions.php
add_filter('wp_nav_menu_items', 'category_list', 10, 2);
function category_list($items, $args)
{
if( $args->theme_location == 'header' )
{
$items .= '<li id="menu-item-184" class="parent menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-184"><a href=""#"">Kategorie</a><ul class="sub-menu">';
$categories = get_categories();
foreach ($categories as $category)
{
$option = '<li><a href="'.get_category_link( $category->term_id ).'">';
$option .= $category->cat_name;
$option .= '</a></li>';
$items .= $option;
}
$items .= '</ul></li>';
}
return $items;
}
How
How I can change the order of this item. I can’t see it in Appearance->menu I want to move it to second position in menu.
Home | Categories | How to start | about | contact
You can’t order it through the wordpress Menu if you’re using a filter. The worpdress menu system gives you the option to add Categories just as you add pages. If you don’t see it, go to Appearance -> Menu and then go to Screen Options (top right of the page) and make sure the option Categories is checked.