Support » Plugin: Photospace Gallery » Shortcode gallery output vs the_content gallery output

  • Hi there,

    I’ve noticed that if I use the standard WordPress gallery inserted into a post, photospace uses the images which are selected in WP’s tinymce gallery. However if I insert a photospace gallery using do_shortcode it uses the images that are attached to the post (and ignores the contents of the tinymce gallery).

    For example: I insert a gallery of five images into my post, and then upload a sixth image to use as a single image further down the same post. If I display this post in my template using the_content the gallery does not contain the sixth image. However if I want to display the gallery alongside the post using do_shortcode (‘[gallery]‘) then the gallery contains the five gallery images AND the sixth image.

    Is there a way to use do_shortcode that doesn’t include the sixth image?


Viewing 5 replies - 1 through 5 (of 5 total)
  • You will notice that the shortcode generated by WordPress now includes the id’s of the images for the gallery

    [gallery ids="2008,1998,1981,1977,1976,1970,1972,1975"]

    You can do the same thing with the the Photospace embed code. If you don’t specify any id’s then it will grab all the images attached to that page. They are attached if they are uploaded to that page.

    Hope that helps!

    Ah, I see, thanks.

    So I would have to specify which images are used in the embed code.

    But does that mean there isn’t any way to display a gallery that the user has tinkered with? e.g. if the user uploads a picture but then removes it from the gallery, or changes the order of the pics, it won’t be reflected in the embed?

    I was hoping for something like do_shortcode [gallery id=1234 whichgallery=firstgallery]

    I’ve cobbled together this ugly workaround:

    $post_content = $post->post_content;
    preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
    $array_ids = explode(",", $ids[1]);
    $csv_ids = implode(",",$array_ids);
    echo do_shortcode('[gallery ids='.$csv_ids.']’);

    This uses preg_match to search through the post content to find the shortcode [gallery ids="a,b,c,d,etc"], grabs the ids, and then uses them in a do_shortcode.

    Whoa, good work I think 😛

    In this case I wouldn’t use this plugin. I would probably use with a repeater of images and setup a gallery manually. This is more user friendly.

    Thanks for that Dean, I’ll check it out (for the next job :P)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shortcode gallery output vs the_content gallery output’ is closed to new replies.