So we keep running into a situation where we would like to have a post redirect to and external link but also open in a new tab from search. We have done it with YOAST but I was wondering is there any other way to do this without YOAST. I have tried multiple plugins and the redirect will work but will not open in a new tab from search,
Hello @b-lynk,
Thanks for writing in!
By default, the post items in the blog index, archive pages, and the search results will open in the same tab. It will not open to a blank new tab. If you want to do that, it will need a custom snippet. Please add this JS code in the Theme Options > Global JS (http://prntscr.com/evswzb)
(function($){
$(".blog .entry-title a, .archive .entry-title a, .search .entry-title a").attr("target", "_blank");
})(jQuery);
We would love to know if this has worked for you. Thank you.
No this doesn’t seem to work as well. Using the Redirection Plugin for the redirect. I put the script and global JS. Also tried it as a post and page. Still opens in same tab… Still no luck.
Hey @b-lynk,
The Javascript code RueNel provided should work. Perhaps there is something on your site that is stopping the code from working or the selectors should be changed on the code. Would you mind providing the URL of the site in question so that we can check it?
Thank you.
Ok here is the URL http://34.234.233.91
If you search for “Getting Started as a User” This is the post I’m testing with
Hey @b-lynk,
Do you mean the search results that display below the search box?
If so, it would be best to check with the original developer of the plugin about this one since the search results are using AJAX and merely adding a JS code to add the blank attribute to the <a>
tag in the search result will not work.
Thank you.
Ok thank you for your help!
You’re most welcome!
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.