Solve the problem of opening a new page
-
This plugin can’t let the link open in a new tab.
My solution to this problem is to paste the code in function.php
Maybe anyone with this problem can try this.
This will make all links not from your domain open as a new tab.add_action( ‘wp_head’, function () { ?>
<script>
window.onload = function() {
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = ‘_blank’;
}
}
}
</script>
<?php } );
- The topic ‘Solve the problem of opening a new page’ is closed to new replies.