Skip to:
Content
Pages
Categories
Search
Top
Bottom

making links in posts open in new window

  • @thetoolman123

    Participant

    Hi there,

    Can anyone tell me which file controls the links in posts so I can make them open in a new window?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • @letovucontent

    Participant

    Add target=”_blank” to a tag.

    @thetoolman123

    Participant

    Thanks. but I want to add it to the code so every link opens in a new window, even if other users post and don’t use <a href… tags

    @webcreations907

    Participant

    Try adding the below to your theme’s functions.php file.

    
    
    function quick_target_blank_link_content($content){
    	$content = str_replace('<a', '<a target="_blank"',$content);
    	return $content;
    }
    
    add_filter( 'bbp_get_topic_content', 'quick_target_blank_link_content', 60 );
    add_filter( 'bbp_get_reply_content', 'quick_target_blank_link_content', 60 );
    
    

    @thetoolman123

    Participant

    Hi,

    Many thanks for the code, that worked perfectly 😀

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