WordPress menu – adding items to a menu without selecting a primary menu manually

I am making a theme for wordpress that makes it in to an app.
I would like the menu items below to show up when runned in header.php – however it only shows up if I activate a new menu with at least one item as primary menu.

I want a user to be able to install wordpress and then just activate the theme (without having to config a menu manually).

Read More

Can I add the items below without having to do the procedure of activating a primary menu? Or any other good workaround.

    add_filter( 'wp_nav_menu_items', 'add_links', 10, 2 );

function add_links( $items, $args ) {
$items = "";
$items .= '<li><a href="'. site_url() .'">Hem</a></li>';
$items .= '<li><a href="'. site_url('about-us') .'">About-us</a></li>';

return $items;
}
        wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu'   ) ); 

Related posts

Leave a Reply

1 comment