Wordpress menu link open in new tab

To make a WordPress menu link open in a new tab, you can use the following methods:

Method 1: Using the target attribute

  1. Log in to your WordPress dashboard.
  2. Go to Appearance > Menus.
  3. Click on the menu item you want to edit.
  4. In the "Link URL" field, add the target="_blank" attribute to the URL. For example: https://www.example.com becomes https://www.example.com target="_blank".
  5. Save the changes.

Method 2: Using a plugin

  1. Install and activate a plugin like "WP Menu Open in New Tab" or "Menu Link Target".
  2. Go to the plugin settings and configure the plugin to open menu links in new tabs.
  3. Save the changes.

Method 3: Using a theme function

  1. Add the following code to your theme's functions.php file:
    function open_menu_links_in_new_tab() {
     return ' target="_blank"';
    }
    add_filter( 'nav_menu_link_attributes', 'open_menu_links_in_new_tab' );
  2. Save the changes.
  3. Go to Appearance > Menus and update the menu.

Method 4: Using a custom CSS

  1. Add the following CSS code to your theme's stylesheet:
    .menu li a {
     target: "_blank";
    }
  2. Save the changes.
  3. Go to Appearance > Menus and update the menu.

Note: The above methods will make all menu links open in new tabs. If you want to make only specific menu links open in new tabs, you can use the target attribute or the plugin method and specify the links individually.