Making an external link open in a new tab in WordPress is easy. Simply add the following code to your theme’s functions.
php file:
I’ve placed this code in the functions.php file of my WordPress theme so that it will work for all my themes.
function openInNewTab() {
if (is_front_page()) {
wp_die(__(‘External link cannot be opened in a new tab.’), E_USER_ERROR);
}
else {
$new_tab = wp_get_current_tab();
$url = get_post_meta($post->ID, ‘_link’, true);
if ($url) {
$new_tab = $url;
}
add_action(‘wp_loaded’, ‘openInNewTab’);
The first line of this function will check to see if the page is the front page. If it is, the function will simply die. If the page isn’t the front page, the function will get the current tab number and use that to determine what tab the user should be in.
The function then checks to see if the link is in the post meta _link field. If it is, the function will change the current tab to the URL that is in the post meta _link field.
9 Related Question Answers Found
External links in WordPress often open in new tabs, but this feature can be disabled in a few easy steps. To make external links open in new tabs in WordPress, follow these steps:
1. Open your WordPress admin area.
2.
Making a custom link open in a new tab in WordPress is easy. First, create a new post or page in WordPress. Then, in the post or page content, include a link to the URL you want the link to open in a new tab.
Making a link open in a new tab by default in WordPress can be done using a few simple steps. First, go to your WordPress admin area and click on the “Settings” link in the left-hand menu. This will take you to the WordPress Settings page.
Making the menu link open in a new tab in WordPress is a quick and easy process. To do this, follow these steps:
1. In the WordPress admin area, go to the “Appearance” tab and under the “Menus” heading, click the “Link to Menu” button.
2.
The Menu Link in WordPress opens in a new tab by default, but you can change this behavior in a few easy steps. First, open the Settings page for your WordPress site. Next, find the “Menus” section and click on the “Add New” button.
An external link is a link to a website other than the one you are currently viewing. In order to create an external link in WordPress, you first need to find the URL of the website you want to link to. Once you have the URL, you can use the WordPress link editor to create the link.
There are a few ways to get a menu link to open in a new tab in WordPress. One way is to use the [Toggle New Tab] shortcode. To use the [Toggle New Tab] shortcode, you must first activate the [Toggle New Tab] plugin.
Creating an external link in WordPress is not as difficult as it may seem at first. In fact, it is quite simple and can be done with a few simple steps. To create an external link in WordPress, first locate the content you want to link to.
Adding an external link to a menu in WordPress is simple. First, locate the menu item that you want to add the link to. Next, locate the “Add a link to this menu” button on the menu.