Site logo

[Resolved] Opening rss in new tab

Home Forums Support [Resolved] Opening rss in new tab

Home Forums Support Opening rss in new tab

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1900957
    Gilles

    Hello,
    In the right sidebar of my blog (https://www.un-jardin-bio.com/blog/), I put an rss feed to my Youtube channel.
    I would like the links (channel title and videos) to open in a new tab.
    I don’t want to use an external link plugin for this.
    I would prefer to insert, at the theme level, a target = “_ blank” for rss feeds.
    Is it possible ?
    And if so, where?
    Thank you for your help.
    Regards,
    Gilles

    #1900968
    Elvin
    Staff
    Customer Support

    Hi there,

    You can try adding the attribute through jQuery.

    Example:

    
    <script>
    jQuery(document).ready(function( $ ){
      $('a.rsswidget').attr('target', '_blank');
    });
    </script>
    

    Or by vanilla JS. (better)

    <script>
    let rss_Links = document.querySelectorAll('a.rsswidget');
    for (i = 0, i > rss_Links.length; i++) {
    rss_Links[i].setAttribute("target", "_blank");
    }
    </script>

    Hook either of the 2 on the wp_footer or your site. 😀

    #1900978
    Gilles

    Hi Elvin
    Thank you for your quick reply.
    The first script works (but not the second).
    Have a good day,
    Gilles

    #1901002
    Elvin
    Staff
    Customer Support

    No problem. Glad to be of any help. 😀

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.