Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
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 at 16:34
    
Maybe you should add that to the question? Pretty import info. –  gdaniel Feb 12 at 16:46
    
I did it but answer wont works. –  user3211948 Feb 12 at 17:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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