Skip to content

Instantly share code, notes, and snippets.

@Sjouw
Created December 9, 2014 12:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sjouw/675db4d4f1e5680f000a to your computer and use it in GitHub Desktop.
Save Sjouw/675db4d4f1e5680f000a to your computer and use it in GitHub Desktop.
WordPress - Add description to featured image field
/*
* Add description to Featured image box
*/
function new_post_thumbnail_meta_box() {
global $post;
$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); // grabing the thumbnail id of the post
echo _wp_post_thumbnail_html( $thumbnail_id ); // echoing the html markup for the thumbnail
echo 'The field description goes here';
}
function render_new_post_thumbnail_meta_box() {
global $post_type; // lets call the post type
// remove the old meta box
remove_meta_box( 'postimagediv','post','side' );
// adding the new meta box.
add_meta_box('postimagediv', __('Featured Image'), 'new_post_thumbnail_meta_box', $post_type, 'side', 'low');
}
add_action('do_meta_boxes', 'render_new_post_thumbnail_meta_box');
@truongluu
Copy link

thanks for your share

@filipecsweb
Copy link

Thanks for sharing.

Instead of writing __('Featured Image') you should write _x('Featured Image', 'post').

@Kenye2000
Copy link

works for me, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment