Title: Gallery Short Code
Last modified: August 20, 2016

---

# Gallery Short Code

 *  Resolved [Robert Dall](https://wordpress.org/support/users/rdall/)
 * (@rdall)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/gallery-short-code-1/)
 * I would rather have a gallery short code that could display the title of the 
   image rather then the caption below the image. As captions can be a couple sentences
   sometimes when you use the thumbnail image for the gallery the caption seems 
   almost as large as the thumbnail image itself.
 * When you look at the media ‘wp-includes/media.php’ it only give you one option
   which is the caption.
 * Of course I can just display the CSS to none and it won’t show anything below
   the image, but I believe their could be better solutions.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/gallery-short-code-1/#post-2326650)
 * you can add your own gallery shortcode to functions.php of your theme, starting
   with a copy of the code from wp_includes/media.php;
 *     ```
       remove_shortcode('gallery', 'gallery_shortcode');
       add_shortcode('gallery', 'rdall_gallery_shortcode');
       function rdall_gallery_shortcode($attr) {
       HERE ADD THE FULL GALLERY CODE FROM MEDIA.PHP, BUT CHANGE THESE LINES:
       		if ( $captiontag && trim($attachment->post_title) ) {
       			$output .= "
       				<{$captiontag} class='wp-caption-text gallery-caption'>
       				" . wptexturize($attachment->post_title) . "
       				</{$captiontag}>";
       HERE THE REST OF THE CODE
       return $output;
       }
       ```
   
 * the full section in one bit:
    [http://pastebin.com/uaLJbDsi](http://pastebin.com/uaLJbDsi)
 *  Thread Starter [Robert Dall](https://wordpress.org/support/users/rdall/)
 * (@rdall)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/gallery-short-code-1/#post-2326694)
 * Thanks Alchymyth! that looks awesome! I will certainly throw this into the function
   file and check it out!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Gallery Short Code’ is closed to new replies.

## Tags

 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Robert Dall](https://wordpress.org/support/users/rdall/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/gallery-short-code-1/#post-2326694)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
