Skip to content

Instantly share code, notes, and snippets.

@gmaggio
Created July 9, 2014 21:39
Show Gist options
  • Save gmaggio/f3b7ba42d9e4ead92c20 to your computer and use it in GitHub Desktop.
Save gmaggio/f3b7ba42d9e4ead92c20 to your computer and use it in GitHub Desktop.
[Wordpress] Insert custom menu items via hard coding
<?php
// Sample: Add HOME link to Nav Menu
function new_nav_menu_items($items, $args) {
if( $args->theme_location == 'primary' ){
$homelink = '<li class="home"><a href="' . home_url( '/' ) . '">' . __('Home') . '</a></li>';
$items = $homelink . $items;
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items', 10, 2 );
/*
Source:
http://wordpress.stackexchange.com/a/60442/1044
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment