Skip to content

Instantly share code, notes, and snippets.

@icetee
Created June 22, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icetee/e380f5426b55293b0c32 to your computer and use it in GitHub Desktop.
Save icetee/e380f5426b55293b0c32 to your computer and use it in GitHub Desktop.
remove_a_tag() in Wordpress
function remove_a_tag($string, $postid, $slug = true) {
$return = array();
preg_match_all("/<a.*?>(.*?)<\/a>/", $string, $matches);
foreach ($matches[1] as $key => $value) {
if ($slug == true) {
$return[] = sanitize_title($value);
} else {
$return[] = $value;
}
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment