[Support request] How to change from open in new window to same window

Home Forums Support How to change from open in new window to same window

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1517309
    Anton

    Hi there,

    Didn’t see an answer to this via search. On my site, I set almost all links (internal and external) to open in a new tab (window). I’d now like to have all internal links open in the same tab, with external links opening in a new tab.

    Or, if it’s simpler, just have all links open in the same tab.

    Is there a way to reliably do this across the board with some Javascript, or otherwise?

    Many thanks (love this theme!!).

    #1517474
    David
    Staff
    Customer Support

    Hi there,

    you could try filtering the content with preg_replace to remove the Target attribute:

    add_filter('the_content', 'db_remove_target_blank_in_content', 15);
    function db_remove_target_blank_in_content($content)
    {
        return preg_replace('#target=["\']?_blank["\']?#mi','',$content);
    }

    I would suggest testing this on a staging site in case it creates any unintentional side effects.

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