Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
добавление логин логаут в меню WP
// Filter output menu add sign in / sign out
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 == 'header_menu') {
$items .= '<li><a href="'. wp_logout_url(home_url()) .'"><i class="icon-user-login-button"></i><span>Выйти</span></a></li>';
elseif (!is_user_logged_in() && $args->theme_location == 'header_menu') {
$items .= '<li><a data-fancybox="" data-animation-duration="700" data-src="#register-popup" href="javascript:;"><i class="icon-Registration-01"></i><span>Регистрация</span></a></li>';
$items .= '<li><a data-fancybox="" data-animation-duration="700" data-src="#login-popup" href="javascript:;"><i class="icon-user-login-button"></i><span>Войти</span></a></li>';
return $items;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.