Skip to content

Instantly share code, notes, and snippets.

@5A5K1A
Created February 27, 2017 01:04
Show Gist options
  • Save 5A5K1A/8c2a7d6b5161691b538dc68c86622a69 to your computer and use it in GitHub Desktop.
Save 5A5K1A/8c2a7d6b5161691b538dc68c86622a69 to your computer and use it in GitHub Desktop.
WordPress Change 'Featured Image' metabox
<?php
/* Featured Image Metabox : change the text in the current metaboxes
/* -------------------------------------------------- */
add_filter( 'admin_post_thumbnail_html', function( $content ) {
if(get_post_type() == 'post') {
$content = str_replace('Uitgelichte afbeelding', 'Nieuws foto', $content);
// $content .= '<p>Een extra uitlegtekst.</p>';
} elseif(get_post_type() == 'page') {
$content = str_replace('Uitgelichte afbeelding', 'Header foto', $content);
}
return $content;
});
/* Featured Image Metabox : change the title & position of the current metaboxes
/* -------------------------------------------------- */
add_action('do_meta_boxes', function() {
// first remove the current metaboxes
remove_meta_box( 'postimagediv', 'post', 'side' );
remove_meta_box( 'postimagediv', 'page', 'side' );
// add some new and improved metaboxes now
// usage: https://developer.wordpress.org/reference/functions/add_meta_box/
add_meta_box('postimagediv', __('Expertise icoon'), 'post_thumbnail_meta_box', 'post', 'side', 'high');
add_meta_box('postimagediv', __('Case foto'), 'post_thumbnail_meta_box', 'page', 'side', 'high');
});
@5A5K1A
Copy link
Author

5A5K1A commented Feb 27, 2017

Can be done now by registering the custom posttype.

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