I have a plugin that need to remove the post thumbnail under certain conditions. Tried to hook to "get_post_metadata" filter but the code doesn't seem to work.
Here's my code:
public function helper() {
...
add_filter('get_post_metadata', array($this, 'removeThumbnail'), 999, 4);
...
}
public function removeThumbnail($metadata, $object_id, $meta_key, $single) {
return ( isset($meta_key) && '_thumbnail_id' === $meta_key ) ? false : $metadata;
}
My class is initialized on the_content hook.
However, it doesn't remove the featured image in the post. Any insights and ideas how to make it happen?