-
-
Save misfist/e268e8f514482090e7dfb9d2ea656864 to your computer and use it in GitHub Desktop.
WordPress - Remove first image from single post content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_remove_first_image( $content ) { | |
if ( !is_page() && !is_feed() && !is_home() ){ | |
$content = preg_replace( "/<img[^>]+\>/i", "", $content, 1 ); | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'prefix_remove_first_image' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment