Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress. Adding menu item manually in wp_nav_menu

Tags:

wordpress

menu

In my theme there is a function for nav menus

function ct_nav() {
  <nav>
     <?php wp_nav_menu( array( 'container_id' => 'nav', 'theme_location' => 'primary') ); ?>
  </nav>
}

How could i add more item manually? using this function alone.

like image 915
user1441797 Avatar asked Sep 11 '12 02:09

user1441797


People also ask

How do I add a menu item?

On the Navigation page, click the title of the menu that you want to edit. Click Add menu item. Enter a name for the menu item. This name displays in the menu, and can include special characters or emoji.

How do I add a custom menu code in WordPress?

To do this go to Appearance >Menus and start creating a new menu. Give the menu the title “Secondary Menu”, select “My Custom Menu” for a location and then hit the “Create Menu” button. Finally add some items to the menu (for example Menu item 1, Menu item 2, Menu item 3) and then save the menu.


1 Answers

function add_last_nav_item($items) {
  return $items .= '<li><a href="#myModal" role="button" data-toggle="modal">Contact</a></li>';
}
add_filter('wp_nav_menu_items','add_last_nav_item');
like image 61
Said Erraoudy Avatar answered Oct 03 '22 01:10

Said Erraoudy