Created
December 9, 2014 12:57
-
-
Save Sjouw/675db4d4f1e5680f000a to your computer and use it in GitHub Desktop.
WordPress - Add description to featured image field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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'); |
Thanks for sharing.
Instead of writing __('Featured Image')
you should write _x('Featured Image', 'post')
.
works for me, thanks for sharing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for your share