自动为wordpress文章内容的链接加上target=”_blank”

找到使用主题的functions.php文件,加入以下内容:

function addTarget($content) {    
 
$result = str_replace('<a', '<a target="_blank"', $content);    
 
return $result;    
 
}    
 
add_filter('the_content', 'addTarget'); 
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享