Last active
October 26, 2022 16:39
-
-
Save brandonbarringer/6bfdbe269e6fd0b4a417a243acfb72b8 to your computer and use it in GitHub Desktop.
Set Helper Text on WP Featured Images
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 | |
add_filter( 'admin_post_thumbnail_html', function($content, $post_id, $thumbnail_id) { | |
if ( 'post_type' !== get_post_type( $post_id ) ) { | |
return $content; | |
} | |
// remove the default recommended size | |
$string = '<p class="hide-if-no-js howto">We recommend a 16:9 aspect ratio for featured images.</p>'; | |
$content = str_replace($string, '', $content); | |
// add a custom caption | |
$caption = '<p class="howto">' . esc_html__( 'Minimum image size: 783x645', 'iv' ) . '</p>'; | |
// return the content with the caption | |
return $content . $caption; | |
}, 10, 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment