Created
February 27, 2017 01:04
-
-
Save 5A5K1A/8c2a7d6b5161691b538dc68c86622a69 to your computer and use it in GitHub Desktop.
WordPress Change 'Featured Image' metabox
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
<?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
Can be done now by registering the custom posttype.