WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Gallery Short Code

[Resolved] Gallery Short Code

  • 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)
  • Moderator Michael

    @alchymyth

    Forum Moderator

    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

    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 ‘[Resolved] Gallery Short Code’ is closed to new replies.