Forums

[resolved] Gallery Shortcode renders different code in RSS2 feed (2 posts)

  1. dskbrk
    Member
    Posted 7 months ago #

    Hello,

    I just noticed that WordPress renders the [gallery] shortcode in a different way for the RSS2 feed.

    Instead of <dl> & <dt> tags there's a plain link for every image, and it always point to the attachment page (instead of image url), like this:

    <a href='<em>attachment page link</em>' title='X'><img width="210" height="160" src="http://..image.jpg" class="attachment-thumbnail" alt="x" title="x" /></a>

    There is a way to render the gallery shortcode in the same way as of the standard HTML output?

    I also wonder if there are other difference between HTML and RSS outputs. I can't find anything about this.

  2. dskbrk
    Member
    Posted 7 months ago #

    in wp-includes/media.php, function gallery_shortcode(), line 811, there's:

    if ( is_feed() ) {
    		$output = "\n";
    		foreach ( $attachments as $att_id => $attachment )
    			$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
    		return $output;
    	}

    I solved copying the whole function without those lines in my theme functions.php with a different name, then adding:

    add_shortcode('gallery', 'gallery_shortcode_fix');

Reply

You must log in to post.

About this Topic