Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Display title instead of caption under images by WP Gallery WordPress

My client (a photographer) is uploading a large amount of images for clients to review photos...

Right now, the custom post type automatically inserts a gallery into the editor, so my client can just add photos by Editing the gallery already inserted into the post.

Since my client is usually uploading a large number of photos (100+), she would like the image title to display under each thumbnail, instead of the default caption... This way she doesn't have to manually enter captions for each and every image, and the client has a file name to reference when reviewing the photos.

How do I modify the default gallery output to display the filename instead of the caption under the thumbnails?

Here's the code I'm using in the functions.php to insert the gallery shortcode:
add_filter( 'default_content', 'my_editor_content', 10, 2 );

function my_editor_content( $content, $post ) {
switch( $post->post_type ) {
case 'client':
$content = '[gallery order="DESC" columns="6" link="file" captiontag="p"]';
return $content;


Answers (4)


Hariprasad Vijayan answers:


Can you please show the url


Naveen Chand answers:

Hi Michael,

Try using this code in your functions.php:

add_filter('attachment_fields_to_edit', 'image_caption_to_title', 11, 2 );

function image_caption_to_title( $form_fields, $post ) {
if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
$form_fields['post_excerpt']['value'] = $post->post_title;
//$form_fields['post_excerpt']['input'] = 'hidden';
return $form_fields;

This will set your caption similar to the title of the image. Let me know if it helps.


Michael Brumm comments:

Hi Naveen,

I added the above code to the functions.php file and gave it a go (by uploading and adding new images to an existing gallery)... It doesn't appear to have worked.

Check out the attached images that show the image in the "Edit Gallery".

Is there anything else I should be aware of when implementing this code?

FYI - Site is currently using WP 3.5.2.