Add a target=”_webapp” to all links on wordpress
-
Hi, I am making my site look like an Application by removing the Safari Toolbars on all apple devices. In order to do this I all links need to target=”_webapp” on the entire wordpress site. I am trying to create a function to do this from some code I grabbed that was creating a target=”_blank” but was for external links only, throughout the website.
Can someone PLEASE assist me with modifying this function to go into my ‘functions.php’ folder.
Or if someone knows of a better method that would be great.
Thanks.Code:
function autowebapp($text) {
$return = str_replace(‘<a href = ‘, ‘<a target = “webapp” href = ‘, $text);
$return = str_replace(‘<a target = “webapp” href = “https://www.mydomain.com’, ‘<a href = “https://www.mydomain.com’, $return);
$return = str_replace(‘<a target = “webapp” href = “#’, ‘<a href = “#’, $return);
$return = str_replace(‘ target = “webapp”>’, ‘>’, $return);
return $return;
}
add_filter(‘the_content’, ‘autowebapp’);
add_filter(‘comment_text’, ‘autowebapp’);
- The topic ‘Add a target=”_webapp” to all links on wordpress’ is closed to new replies.