Title: Gallery shortcode doesn&#8217;t work
Last modified: August 19, 2016

---

# Gallery shortcode doesn’t work

 *  [dansafary](https://wordpress.org/support/users/dansafary/)
 * (@dansafary)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/gallery-shortcode-doesnt-work/)
 * Gallery shortcode doesn’t work,
    is it just me, or you have the same problem ??
 * `[gallery columns="2"]`
 * this is supposed to work right ?? but it doesn’t . -_-
    ??

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

 *  [Sherwin Techico](https://wordpress.org/support/users/sherwin/)
 * (@sherwin)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/gallery-shortcode-doesnt-work/#post-924957)
 * Same here. And just using a simple [gallery]
 *  [rhayashida](https://wordpress.org/support/users/rhayashida/)
 * (@rhayashida)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/gallery-shortcode-doesnt-work/#post-924959)
 * I found a solution to this problem. Goto to this section of wp-includes/post-
   template.php and replace the code.
 * /**
    * Retrieve an attachment page link using an image or icon, if possible. **
   [@since](https://wordpress.org/support/users/since/) 2.5.0 * @uses apply_filters()
   Calls ‘wp_get_attachment_link’ filter on HTML content with same parameters as
   function. * * [@param](https://wordpress.org/support/users/param/) int $id Optional.
   Post ID. * [@param](https://wordpress.org/support/users/param/) string $size 
   Optional. Image size. * [@param](https://wordpress.org/support/users/param/) 
   bool $permalink Optional, default is false. Whether to add permalink to image.*
   [@param](https://wordpress.org/support/users/param/) bool $icon Optional, default
   is false. Whether to include icon. * [@return](https://wordpress.org/support/users/return/)
   string HTML content. */
 *     ```
       function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
       	$id = intval($id);
       	$_post = & get_post( $id );
   
       	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
       		return __('Missing Attachment');
   
       	if ( $permalink )
       		$url = get_attachment_link($_post->ID);
   
       	$post_title = attribute_escape($_post->post_title);
   
       	$link_text = wp_get_attachment_image($id, $size, $icon);
   
       	//modification introduced to force the gallery shortcode thumbnail hyperlink to the full size image directly, rather than the attachment page
       		$url = wp_get_attachment_url($_post->ID);
   
       	if ( !$link_text )
       		$link_text = $_post->post_title;
   
       	return apply_filters( 'wp_get_attachment_link',"<a href=$url title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
       }
       ```
   
 * Make sure to backup your post-template.php file before modifying the code. Thanks
   to Mark Pederson for the solution.
 * R
 *  [kristina108](https://wordpress.org/support/users/kristina108/)
 * (@kristina108)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/gallery-shortcode-doesnt-work/#post-925259)
 * This didn’t work for me. Did it work for anyone else?
 * Cheers,
    Kristina

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

The topic ‘Gallery shortcode doesn’t work’ is closed to new replies.

## Tags

 * [bugs](https://wordpress.org/support/topic-tag/bugs/)
 * [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/)
 * 3 replies
 * 4 participants
 * Last reply from: [kristina108](https://wordpress.org/support/users/kristina108/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/gallery-shortcode-doesnt-work/#post-925259)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
