Last active
August 6, 2019 11:40
-
-
Save Trovin/854b3c3d254da284b1eab6c22d52bd94 to your computer and use it in GitHub Desktop.
Wp add description to Featured image box
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
/** | |
* Add description to Featured image box | |
*/ | |
function admin_post_thumbnail_descr( $content, $post_id, $thumbnail_id ) { | |
$caption = '<p style="color: #c04747;">' . esc_html__( 'Minimum image size: ', 'i18n-tag' ) . '</p>'; | |
$caption2 = '<p style="color: #c04747;">' . esc_html__( 'width:800px; height: 300px;', 'i18n-tag' ) . '</p>'; | |
return $content . $caption . $caption2; | |
} | |
add_filter( 'admin_post_thumbnail_html', 'admin_post_thumbnail_descr', 10, 3 ); | |
Add only selected post type | |
=========================== | |
function admin_post_thumbnail_descr( $content, $post_id, $thumbnail_id ) { | |
if ( 'post' !== get_post_type( $post_id ) ) { | |
$caption = '<p>' . esc_html__( 'Recommended image size: 1300px (width) x 340px (height)', 'i18n-tag' ) . '</p>'; | |
return $content; | |
} | |
} | |
add_filter( 'admin_post_thumbnail_html', 'admin_post_thumbnail_descr', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment