WordPress.org

Ready to get started?Download WordPress

Forums

Gallery shortcode doesn't work (4 posts)

  1. dan.safary
    Member
    Posted 5 years ago #

    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 . -_-
    ??

  2. Sherwin Techico
    Member
    Posted 5 years ago #

    Same here. And just using a simple [gallery]

  3. rhayashida
    Member
    Posted 5 years ago #

    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 2.5.0
    * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
    *
    * @param int $id Optional. Post ID.
    * @param string $size Optional. Image size.
    * @param bool $permalink Optional, default is false. Whether to add permalink to image.
    * @param bool $icon Optional, default is false. Whether to include icon.
    * @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

  4. kristina108
    Member
    Posted 5 years ago #

    This didn't work for me. Did it work for anyone else?

    Cheers,
    Kristina

Topic Closed

This topic has been closed to new replies.

About this Topic