How to add Target Blank to WordPress Menu Custom Link

How to add Target Blank to WordPress Menu Custom Link

How to add a target _blank on a WordPress menu item

The WordPress menu allows custom links to be added.

This is a great way to complement your menu pages with specific additional references. Links may be to social media, business or trade organizations, agents, or other related websites.

The Menus module is one of those amazing features, but by default, it does not allow specifying certain features of menu items such as “target”.

Read this: Add templet/theme in blogger

Method 1: Screen Options

Follow the Five Easy step to set target _blank on a WordPress menu item

  • In WordPress dashboard Go to the “Appearance”.
  • Choose “Menus Option”.
  • Then, click on the “Screen Options” button. located on the top right corner.
  • Check Mark On Link Target Check Box.
  • Now go to Custom Menu Link Option.
Add-Target-Blank-to-WordPress-Menu-Custom-Link

Method 2 :- Add target_blank” Using to PHP code

In function.php Page Add this code

add_filter( ‘related_posts_by_taxonomy_post_link’, ‘related_posts_add_target_blank’, 10, 3); function related_posts_add_target_blank( $link, $post, $link_attr ) { $permalink = get_permalink($post); $link = “<a href='{$permalink}’ target=’_blank’>{$link_attr[‘title’]}</a>”; return $link; }



add_filter( 'related_posts_by_taxonomy_post_link', 'related_posts_add_target_blank', 10, 3); function related_posts_add_target_blank( $link, $post, $link_attr ) { $permalink = get_permalink($post); $link = "<a href='{$permalink}' target='_blank'>{$link_attr['title']}</a>"; return $link; }

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!