Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function replace_thumbnail( $id, $object_id, $meta_key ) {
- if ( '_thumbnail_id' === $meta_key && 'post' === get_post_type( $object_id ) ) {
- remove_filter( 'get_post_metadata', __FUNCTION__ );
- $default_id_img = 91;
- $id = has_post_thumbnail( $object_id ) ? $id : $default_id_img;
- add_filter( 'get_post_metadata', __FUNCTION__, 10, 4 );
- }
- return $id;
- }
- add_filter( 'get_post_metadata', 'replace_thumbnail', 10, 3 );
Add Comment
Please, Sign In to add comment