Want to know what WordPress Theme a site is using? Check Out Now!

How to Open All WordPress Post Links in New Tab?

Opening links in a new tab is one of the common tactics to increase dwell time on a web page.

WordPress does allow you to open links in a new tab but you have to go to each link and turn on the setting individually.

But, with the below code, you can set all WordPress post links to open in a new tab.

 * Open all WordPress links in new tab
 * @param string $text WordPress Post Content
 * @return string $text WordPress Post Content
function maverick_target_blank($text)
    $return = str_replace('<a', '<a target = "_blank"', $text);
    return $return;

add_filter('the_content', 'maverick_target_blank');

Leave a Reply

Your email address will not be published. Required fields are marked *