Skip to content

Instantly share code, notes, and snippets.

@davekuhar
Last active July 19, 2019 20:25
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 davekuhar/36d339ea401cdd876f471a9db88e97e3 to your computer and use it in GitHub Desktop.
Save davekuhar/36d339ea401cdd876f471a9db88e97e3 to your computer and use it in GitHub Desktop.
/* remove pesky youtube links from post excerpts */
add_filter('wpv_filter_post_excerpt', 'xmit_remove_youtubelinks');
function xmit_remove_youtubelinks($excerpt){
return $excerpt = preg_replace('~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i', '', $excerpt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment