0

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
0

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.

  • Yes, I know it but I need to add categories to my menu automatically. When I create new category it should appear in menu too. – user3211948 Feb 12 '14 at 16:34
  • Maybe you should add that to the question? Pretty import info. – gdaniel Feb 12 '14 at 16:46
  • I did it but answer wont works. – user3211948 Feb 12 '14 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.