Last active
April 22, 2023 02:51
-
-
Save phillip-boombox/17d7359c306f8db2f1c47920e6e9cd99 to your computer and use it in GitHub Desktop.
WordPress: Add help text to the featured image metabox.
This file contains 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 | |
/** | |
* Add guidance text to the featured image metabox. | |
* Filter: admin_post_thumbnail_html | |
* | |
* @param string $content Meta box HTML | |
* @param integer $post_id ID of post | |
* @return string | |
*/ | |
function cmfy_featured_image_help_text( $content, $post_id ) { | |
// Limit text to certain post types | |
if ( 'page' == get_post_type( $post_id ) ) { | |
$content .= sprintf( '<p>%s<p>', __( 'For best results, this image should be 900 pixels wide x 506 pixels tall or else it could be cropped unexpectedly. ', 'cmfy' ) ); | |
} | |
return $content; | |
} | |
add_filter( 'admin_post_thumbnail_html', 'cmfy_featured_image_help_text', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment