How to Hide Feature Image of Posts in WordPress?


By default, many wordpress themes e.g. 2017 (twenty-seventeen) show the feature image on the top of the posts. The feature image is defined per post basis and is useful in displaying the thumbnails, but we don’t want to show it above the post.

You could edit the template file, usually content.php and remove the corresponding feature image HTML code e.g. div+img, however, below is a quick and most efficient way of hiding the feature images of all posts in WordPress.

You need to add the following PHP code to the functions.php template e.g. under the child theme. Save the template file and clear any cache if applicable. The feature image will not be displayed anymore.

1
2
3
4
5
function wordpress_hide_feature_image( $html, $post_id, $post_image_id ) {
  return is_single() ? '' : $html;
}
// add the filter
add_filter( 'post_thumbnail_html', 'wordpress_hide_feature_image', 10, 3 );
function wordpress_hide_feature_image( $html, $post_id, $post_image_id ) {
  return is_single() ? '' : $html;
}
// add the filter
add_filter( 'post_thumbnail_html', 'wordpress_hide_feature_image', 10, 3 );

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
222 words
Last Post: The 404-not-found Code of StackOverFlow
Next Post: How to Remove an Item in a List (Good Taste and Bad Taste)?

The Permanent URL is: How to Hide Feature Image of Posts in WordPress?

One Response

  1. Jason

Leave a Reply