Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to get a specific Gallery ID inserted to a post in wordpress 3.5? I want to load gallery from post using Ajax. I use shortcode [gallery] to do it. But when I use it this way:

echo do_shortcode('[gallery id="'.$_POST['postid'].'"]');

I get all images attached to the post with $_POST['postid'] and not images from the gallery which is inserted to that post.

share|improve this question
The second one helped me, thank you. –  Paul Jan 15 '13 at 12:18

2 Answers 2

The plain, old [gallery] should still work here.

share|improve this answer

In single.php i put this code, from this link (thank you Wyck) http://stackoverflow.com/questions/14277794/wordpress-3-5-own-gallery-with-included-images-doesnt-work

preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
$array_id = explode(",", $ids[1]);

Now I can use gallery shortcode [gallery ids=" id's from $array_id here "]

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.