I've enabled my theme with featured image support. The one thing missing is the ability to add a user-defined hyperlink to the image.

I'm pretty sure I can add a custom field, which I can then use to link to the image. However, I'd like this input field to be close to the featured image itself.

Ideally, just below the "Remove Featured Image" link and inside the featured image div.

I'd appreciate any help or insights you can provide to get my custom field attached to the featured image panel.

1 Answer 1


you can do that in many ways , for example :

 add_filter( 'admin_post_thumbnail_html', 'add_something_to_feature_thumb_box');
    function add_something_to_feature_thumb_box( $myhtml ) {
        return $myhtml .= '<p>Put your HTML here - if you want a form, put the form.</p>';

or (better IMHO) :

function replace_post_thumbnail_box() {
        global $post; // get post

        echo '<p> if you want custom field above place code here .</p>';

        $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); // thumbnail ID from post array
        echo _wp_post_thumbnail_html( $thumbnail_id );

        echo '<p>if you want custom field below place  code here .</p>';
function render_new_post_thumbnail_meta_box() {
        global $post_type; 

        // get rid of the old  box..
        remove_meta_box( 'postimagediv','post','side' );

        // ..and render the new one
        add_meta_box('postimagediv', __('Featured Image'), 'replace_post_thumbnail_box', $post_type, 'side', 'low');
add_action('do_meta_boxes', 'render_new_post_thumbnail_meta_box');

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