Skip to content

Instantly share code, notes, and snippets.

@brentini
Forked from 5A5K1A/wordpress-hooks-metabox.php
Last active March 23, 2018 21:27
Show Gist options
  • Save brentini/5596defdb7372e69b7756f12ffb0a725 to your computer and use it in GitHub Desktop.
Save brentini/5596defdb7372e69b7756f12ffb0a725 to your computer and use it in GitHub Desktop.
WordPress Change 'Featured Image' metabox #wordpress
<?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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment