1

How do I add some guiding text under the 'Featured Image'.

Right here:

Guiding text for featured image

I have experienced several times now that people don't get where and what this is. So it could be nice to be able to add a line or two.


If I Google it, then I just get a bazillion pages about how to display the caption in the frontend. :-/

2 Answers 2

1

If you are using the Classic Editor of wordpress, there is a function for this: https://developer.wordpress.org/reference/hooks/admin_post_thumbnail_html/

So the code would be (example from link):

function filter_featured_image_admin_text( $content, $post_id, $thumbnail_id ){
    $help_text = '<p>' . __( 'Please use an image that is 1170 pixels wide x 658
    pixels tall.', 'my_textdomain' ) . '</p>';
    return $help_text . $content;
}
add_filter( 'admin_post_thumbnail_html', 'filter_featured_image_admin_text', 10, 3 );

Remember to set the textdomain of your theme.


If you are using the Gutenberg editor, this is a litte more complex. The filter does not seem to work for gutenberg. As it is made with React JS, I assume it is working differently. Maybe this link can help you: https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/post-featured-image#postfeaturedimage

Moreover I found something that can really help you:

https://thatdevgirl.com/blog/wordpress-featured-image-and-gutenberg

This tutorial can guide you how to adjust the featured image box with filters for gutenberg editor.

Hope this is a starting point for you, if you want to use Gutenberg.


You can also create a custom field of the type of image (Plugin -> Advanced Custom Fields) and use this for the image output in your template. This way you can style the box as you want, add description or whatever you like.

1

Are you using the classic editor you could try this function:

function custom_admin_post_thumbnail_html( $content ) {
    return $content = str_replace( __( 'Set featured image' ), __( 'better feature image guide text' ), $content); 
}
add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' );

Just replace the "better feature image guide text" with whatever you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.