Secondary menu
-
I am using the Twenty Twenty-one template in my WordPress site.
I am trying to add a code snippet in my site so it shows a secondary menu only when the user logs in the system. I already created a secondary empty menu. I am using the following code snippet but it would not work:
function add_login_logout_register_menu( $items, $args ) { if ( $args->theme_location != 'secondary-menu' ) { return $items; } if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $items .= "Hola " . esc_html( $current_user->user_login ) . " | "; $items .= '<a href="' . wp_logout_url() . '">CERRAR SESIÓN</a>'; } else { $items .= '<a href="/login">INICIAR SESIÓN</a>'; $items .= '<a href="/registro">CREAR CUENTA</a>'; } return $items; } add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 10, 2 );The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Secondary menu’ is closed to new replies.