In our Directory theme and all its child themes We have this hard coded logout link in the top navigation menu.
Recently, we have received multiple support queries regarding how to remove that logout link from top navigation menu.
In this article, we will show you how to remove that logout link from the menu which is provided by default.
You can remove the logout link by following any of these two ways:
1. Through functions.php file.
2. Through CSS.
1. Through functions.php file:
Open file named “functions.php” from /wp-content/themes/Directory/ folder on your site. Find this mentioned code in between line number 186 to 194.
Code:
$loginlink = '<li class="tmpl-login' . ((is_home()) ? ' ' : '') . '"><a href="' . wp_logout_url(home_url()) . '">' . __('Log out', DOMAIN) . '</a></li>';
Please comment out this code. So it will look like this:
/*$loginlink = '<li class="tmpl-login' . ((is_home()) ? ' ' : '') . '"><a href="' . wp_logout_url(home_url()) . '">' . __('Log out', DOMAIN) . '</a></li>';*/
COMMENT OUT EVERYTHING BETWEEN THE “if” “else” STATEMENTS SEPARATELY FOR EACH OF THE 4 LINES
2. Through CSS:
However, it is always better if you use Custom CSS to handle this that way it does not get overwritten after an update. Here is the correct CSS to hide those links.
CSS Code:
li.tmpl-login{ display:none !important; }
Hope this helps!