Prevent post images from being displayed on homepage
April 4, 2009 · Print This Article
When using images in your posts, you not always want them to be shown on your blog homepage.
How to prevent any images from the post to be displayed on the homepage?
It is easy, Simply paste this code in your functions.php file:
<?php
add_filter('the_content','wpi_image_content_filter',11);
function wpi_image_content_filter($content){
if (is_home() || is_front_page()){
$content = preg_replace("/<img[^>]+\>/i", "", $content);
}
return $content;
}
?>
Comments
Got something to say?
You must be logged in to post a comment.