I have a website and I want to add automatically categories to my menu. I mean when I create new category it should appear in my menu. How I can make it?
<?php wp_nav_menu( array( 'theme_location' => 'header', 'container' => '' ) ); ?>
Home | Categories | Contact
category1
category2
category3
Something along these lines should at least get your started. You’ll need to register the menu first and get the ID. I didn’t get to deleting categories but you’ll need to take care of that as well.
This is largely untested. Back up your DB first!!
If you want to bulk add existing categories (though it’s pretty easy to do it manually via the admin) something along these lines should work. Run it once and remove it from your functions.php.
I added it to functions.php but nothing happend