1

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.

1

2 Answers 2

2

In single.php i put this code, from this link (thank you Wyck) https://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]);
print_r($array_id);

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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