• I’m trying to add a “Log out” menu item in the Twenty Twenty-Four theme but since it doesn’t use the normal WP menus, then none of the online suggestions work. I’d like to use something like this:

    add_filter( 'wp_nav_menu_items', 'wti_loginout_menu_link', 10, 2 );

    function wti_loginout_menu_link( $items, $args ) {
    if ($args->theme_location == 'primary') {
    if (is_user_logged_in()) {
    $items .= '<li class="right"><a href="'. wp_logout_url() .'">Log Out</a></li>';
    } else {
    $items .= '<li class="right"><a href="'. wp_login_url(get_permalink()) .'">Log In</a></li>';
    }
    }
    return $items;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Log out menu item’ is closed to new replies.