Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #892257
    Naturalife
    Participant

    Hello,

    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!

    #892934
    Prasant Rai
    Moderator

    Hello 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.

    #893979
    Naturalife
    Participant

    I 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.

    #894854
    Rupok
    Member

    Hi 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!

    #896875
    Naturalife
    Participant

    I 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.

    #897601
    Thai
    Moderator

    Hi There,

    Please update the previous code a bit:

    (function($){
      $('.entry-title a, .entry-content.content a').attr('target', '_blank');
    })(jQuery);

    Hope it helps 🙂

    #898820
    Naturalife
    Participant

    That 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.

    #899761
    Christopher
    Moderator

    Hi there,

    Please update your code to :

    (function($){
      $('.single-post .entry-title a, .entry-content.content a').attr('target', '_blank');
    })(jQuery);

    Hope that helps.

    #912666
    Naturalife
    Participant

    Unfortunately 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?

    #913018
    Jade
    Moderator

    Hi 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 credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #982721
    Naturalife
    Participant
    This reply has been marked as private.
    #983076
    Friech
    Moderator

    Hi 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!

    #984279
    Naturalife
    Participant

    That worked, thanks!

    #984412
    Prasant Rai
    Moderator

    You are most welcome. 🙂

    #1058124
    lucascolepeters
    Participant

    Is there a way to open only blogs that are links to another website in a new page?

  • <script> jQuery(function($){ $("#no-reply-892257 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>