Last active
August 29, 2015 13:57
-
-
Save andornagy/9393711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_nav_menu_items','add_custom_in_menu', 10, 2); | |
function add_custom_in_menu( $items, $args ) { | |
if( $args->theme_location == 'primary') { | |
$items .= '<-- Your content here -->'; | |
} | |
return $items; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_nav_menu_items','add_todaysdate_in_menu', 10, 2); | |
function add_todaysdate_in_menu( $items, $args ) { | |
if( $args->theme_location == 'primary') { | |
$todaysdate = date('l jS F Y'); | |
$items .= '<li>' . $todaysdate . '</li>'; | |
} | |
return $items; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 ); | |
function add_loginout_link( $items, $args ) { | |
if (is_user_logged_in() && $args->theme_location == 'primary') { | |
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>'; | |
} | |
elseif (!is_user_logged_in() && $args->theme_location == 'primary') { | |
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>'; | |
} | |
return $items; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2); | |
function add_search_box_to_menu( $items, $args ) { | |
if( $args->theme_location == 'primary' ) | |
return $items."<li class='menu-header-search'><form action='".site_url()."' id='searchform' method='get'><input type='text' name='s' id='s' placeholder='Search'></form></li>"; | |
return $items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment