How to create and populate with few links a menu in child theme functions.php?
The official Twenty Thirteen theme defines just a single menu in the /wp-content/themes/twentythirteen/header.php file:
?php wp_nav_menu( array(
'theme_location' = 'primary',
'menu_class' = 'nav-menu',
'menu_id' = 'primary-menu' ) ); ?
In the child theme of my website I am trying to populate that menu programmatically in the /wp-content/themes/twentythirteen-child/functions.php file, because:
- It makes reinstalling the website easier (less manual steps).
- The last menu item should point to /player-ID link.
So I have tried to add the code:
function my_register_menus() {
register_nav_menus( array(
'primary-menu' = __( 'Primary Menu' ),
)
);
}
add_action( 'init', 'my_register_menus' );
but that does not change anything in the appearance of the website.
Also I have (re)read Navigation Menus in Theme Handbook (incl. API links) and still don't understand, how to pass an array of links to the menu.
I probably should call wp_nav_menu() with some array of objects, but can not find the desciption of such objects.
At the end I would like to add 4 links to the menu:
- "Play game" -
/
- "Android" -
/android
- "iOS" -
/ios
- "Your profile" -
/player-ID
(will takeID
from wp_get_current_user())
Topic theme-twenty-thirteen child-theme theme-development menus Wordpress
Category Web