Skip to content

Instantly share code, notes, and snippets.

@jauhari
Last active February 20, 2017 11:58
Show Gist options
  • Save jauhari/2db6d6faa7983d3a9097126efaa5f501 to your computer and use it in GitHub Desktop.
Save jauhari/2db6d6faa7983d3a9097126efaa5f501 to your computer and use it in GitHub Desktop.
Remove Image and wp caption on Content Frontpage WordPress
<?php
function dhw_remove_img($content) {
if (!is_single()):
// REMOVE IMAGE ONLY $content = preg_replace("/<img[^>]+\>/i", "", $content);
$content = preg_replace("#\s*\[caption[^]]*\].*?\[/caption\]\s*#is", "", $content);
endif;
return $content;
}
add_filter( 'the_content', 'dhw_remove_img' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment