Skip to content

Instantly share code, notes, and snippets.

View wpgaurav's full-sized avatar
👋
Hello!

Gaurav Tiwari wpgaurav

👋
Hello!
View GitHub Profile
@wpgaurav
wpgaurav / functions.php
Created May 10, 2020 16:10 — forked from grtaylor2/functions.php
How to Add a Login/Logout Link to Your WordPress Genesis
<?php // add everything except for this opening line to your functions file
add_filter( 'wp_nav_menu_items', 'sp_add_loginout_link', 10, 2 );
function sp_add_loginout_link( $items, $args ) {
// Change 'primary' to 'secondary' to put the login link in your secondary nav bar
if ( $args->theme_location != 'primary' )
return $items;
if ( is_user_logged_in() ) {
$items .= '<li class="menu-item"><a href="'. wp_logout_url() .'">Log Out</a></li>';
} else {
$items .= '<li class="menu-item"><a href="'. site_url('wp-login.php') .'">Log In</a></li>';