Skip to content

Instantly share code, notes, and snippets.

@yozzi
Created September 15, 2015 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yozzi/9bfd115332df4b962655 to your computer and use it in GitHub Desktop.
Save yozzi/9bfd115332df4b962655 to your computer and use it in GitHub Desktop.
Adding static menu items to wp_nav_menu()
<?php
function my_nav_wrap() {
// default value of 'items_wrap' is <ul id="%1$s" class="%2$s">%3$s</ul>'
// open the <ul>, set 'menu_class' and 'menu_id' values
$wrap = '<ul id="%1$s" class="%2$s">';
// get nav items as configured in /wp-admin/
$wrap .= '%3$s';
// the static link
$wrap .= '<li class="my-static-link"><a href="#">My Static Link</a></li>';
// close the <ul>
$wrap .= '</ul>';
// return the result
return $wrap;
}
?>
<nav>
<?php wp_nav_menu(array(
'theme_location' => 'my_menu_location',
'items_wrap' => my_nav_wrap()
)); ?>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment