Tagged: x
-
AuthorPosts
-
April 20, 2016 at 1:10 pm #892257
NaturalifeParticipantHello,
Is there a way to tag only the blog / article pages and make all current and future posts have links that open in a new window? This would save tons of time so I wouldn’t have to do it manually for every link.
I’m assuming there is a simple way to do this in custom CSS.
Thanks!
April 20, 2016 at 10:50 pm #892934
Prasant RaiModeratorHello There,
Thanks for writing in!
To open posts in a new tab automatically, please add the following JS code in the customizer, Appearance > Customize > Custom > Javascript:
(function($){ $('.entry-title a').attr('target', '_blank'); })(jQuery);Let us know how it goes.
Thanks.
April 21, 2016 at 11:35 am #893979
NaturalifeParticipantI tried that but I’m not sure if it worked. I made one of my post’s links default (so it doesn’t open in a new tab). When I clicked the link, it didn’t open in a new tab like the javascript code should make it do.
Here is the post: http://naturalife.org/natural-life/how-artificial-light-disrupts-your-sleep
The tested link: “suppresses the production of melatonin.”
Any other suggestions?
Thanks again.
April 22, 2016 at 1:22 am #894854
RupokMemberHi there,
Thanks for writing back. I can see the code is working and your links on blog listing pages/category pages are opening in new tab. Would you kindly check again and give us the exact page URL where the mentioned link exists?
Cheers!
April 23, 2016 at 2:01 pm #896875
NaturalifeParticipantI created a new post and none of the links within the article open in a new tab.
Here is the URL: http://naturalife.org/nutrition/health-benefits-fermented-food
Any help would be greatly appreciated.
April 24, 2016 at 12:51 pm #897601
ThaiModeratorHi There,
Please update the previous code a bit:
(function($){ $('.entry-title a, .entry-content.content a').attr('target', '_blank'); })(jQuery);Hope it helps 🙂
April 25, 2016 at 10:50 am #898820
NaturalifeParticipantThat worked, thanks!
EDIT: I noticed this makes posts open in a new tab when I click any posts on the recent posts shortcode. Is there any way to make it so this doesn’t happen? I just want the links WITHIN the articles to open in a new tab.
Thank you.
April 26, 2016 at 1:00 am #899761
ChristopherModeratorHi there,
Please update your code to :
(function($){ $('.single-post .entry-title a, .entry-content.content a').attr('target', '_blank'); })(jQuery);Hope that helps.
May 4, 2016 at 10:44 am #912666
NaturalifeParticipantUnfortunately the links on buttons on my home page (e.g., “view all articles”) and the recent posts links still open in a new tab. Any other suggestions?
May 4, 2016 at 2:13 pm #913018
JadeModeratorHi there,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
May 9, 2016 at 1:19 pm #982721
NaturalifeParticipantThis reply has been marked as private.May 9, 2016 at 5:13 pm #983076
FriechModeratorHi There,
Please update the code to:
jQuery(document).ready(function($){ $(".single-post .entry-title a, .single-post .entry-content a").attr("target", "_blank"); });Hope it helps, Cheers!
May 10, 2016 at 10:41 am #984279
NaturalifeParticipantThat worked, thanks!
May 10, 2016 at 11:57 am #984412
Prasant RaiModeratorYou are most welcome. 🙂
June 24, 2016 at 9:41 am #1058124
lucascolepetersParticipantIs there a way to open only blogs that are links to another website in a new page?
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-892257 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
