Open All WordPress Internal Links in the Same Tab – 3 Different Ways

Estimated reading time: 3 minutes

Last updated on March 26th, 2024 at 07:21 am

Do you want to know “How to Open WordPress Internal Links in Same Tab”?

Imagine you’re on a website built with WordPress, like clicking on a link that takes you to another part of the same website.

Now, normally, when you click on a link, it might open in a new tab, right?

But what if you want it to open in the same tab you’re already using?

Opening WordPress internal links in the same tab is important because it keeps your visitors on your website without opening lots of new tabs.

It gives them a smooth browsing experience, like flipping through pages in a book instead of opening new books each time.

And here’s a cool fact: Did you know that keeping visitors on your site longer can improve your website’s ranking on search engines like Google?

It’s true! When people spend more time on your site, search engines see it as a sign that your site has valuable content.

So, by making sure your WordPress internal links open in the same tab, you’re not just making things easier for your visitors, but you’re also helping boost your website’s visibility online!

3 Ways to Open WordPress Internal Links in the Same Tab

1. Manually

This is like taking matters into your own hands.

You can manually set the links to open in the same tab when you’re creating or editing content in WordPress.

When inserting or editing a link, leave the checkbox “Open link in a new Tab”.

Also Read  Top Table Of Contents Plugin For WordPress - Tried and Tested

open link in new tab

2. Using Plugin

There are plugins available that specifically allow you to control how internal links open, making it easier for you to manage this aspect of your website.

One of the recommended plugin is External Links by Webfactory Ltd.

internal links open in new tab

3. Using Code

Now, this might sound a bit more technical, but it’s like adding a special instruction manual to your website.

By using a bit of code, you can customize how internal links behave, ensuring they open in the same tab.

It’s like giving your website a set of rules to follow.

To use this code, you need to install a plugin WP Code. 

It is my recommended plugin which is used by millions of WordPress users including me.

With this plugin you can get a lot of prebuilt code snippets to use instantly, also you can use your own codes without any hassle.

So, that’s why I prefer this method instead of going to theme functions.php files and other methods.

Follow these steps:

1. Install and Activate the WP Code Plugin

install wp code plugin

2. Visit Add Snippet

visit add snippet

3. Click on “Create your Own”

click create your own

4. Copy Paste This Code and Activate

document.addEventListener(‘DOMContentLoaded’, function() {
var internalLinks = document.querySelectorAll(‘a[href^=”‘ + window.location.origin + ‘”]’);
internalLinks.forEach(function(link) {
link.setAttribute(‘target’, ‘_self’);

internal links same tab code script

Make sure to select the HTML Snippet in the code type.

You can also name the code snippet like I named “Internal Links Same Tab”.

Finally active the code snippet and done.

Wrapping Up – How to Open WordPress Internal Links in Same Tab

Knowing how to make links on your WordPress website open in the same tab is crucial for making it easier for visitors to navigate.

Also Read  Cloudflare Page Rules for WordPress - Useful and Top Rated for Best Performance

Whether you do it by manually adjusting the links or using special plugins, it helps keep people focused and makes the site more user-friendly.

By doing this, you ensure that when someone clicks a link, they stay on the same page instead of opening a new one, which can be confusing.

It’s all about making your website easier to use and keeping visitors happy!