I have the following function:
function remove_images( $content ) {
if( ( is_category() || is_archive() || is_home() ) && has_term( 'MyCat', 'category', $postID ) ) {
$postOutput = preg_replace("/\< *[img][^\>]*[.]*\>/i","",$content,1);
return $postOutput;
}
}
add_filter( 'the_content', 'remove_images', 100 );
What it is meant to do is remove the first image in the_content() on thew index page (all listing pages) only for those posts in the MyCat category. What it is doing, instead, is removing the first image from the_content() on all posts for the index page, and removing the_content() altogether on all of the single pages. Any help would be appreciated. Thank you.
$postID
come from?$postID = get_the_ID();
I defined it above the function. Could that be causing the problem?null
.