have WP Gallery display the title instead of caption

The quick & dirty way, to set the title as caption, would be to use SQL (untested):

UPDATE wp_posts 
SET post_excerpt = post_title 
WHERE  
        post_excerpt="" 
    AND post_type="attachment" 
    AND post_status="inherit"
    AND post_mime_type="image/jpeg"
    AND ID              = 123

Here we target the jpeg image with ID 123 and empty caption.

Note I added the ID = 123 and post_mime_type="image/jpeg" as extra
restrictions that you can adjust while testing. Also remember to
adjust the table name of wp_posts.

WARNING: Backup your database before testing!

If you’re looking for a dynamic way, then my answer here might be related.

It might also be possible for you to add the caption while uploading your images:

/**
 * Automatically set the title as caption, when uploading an attachment.
 *
 * @see https://wordpress.stackexchange.com/a/188708/26350
 */
add_filter( 'wp_insert_attachment_data', function( $data, $postarr )
{    
    // Let's target only the uploading process and not the updating of attachments:
    if( empty( $data['post_excerpt'] ) && isset( $postarr['ID'] ) && 0 == $postarr['ID'] )
        $data['post_excerpt'] = $data['post_title'];

    return $data;
}, 10, 2 );    

Leave a Comment