Extracting a post's gallery shortcode (if it contains one)?
-
Possible? I have a unique situation where I need to be able to tell if a post contains a gallery shortcode and if it does, extract it and use it elsewhere. I know I can tell if a post contains the shortcode using this:
if ( gallery_shortcode($post->ID) ){ //do stuff }
but I’m not sure what my next step would be. I’d like to do something like this:
if ( gallery_shortcode($post->ID) ){ $gallery = extract_gallery() //(function that I'm hoping exists); do_shortcode($gallery); echo "<div id='wrapper-div'">; echo strip_shortcodes($post->post_content); echo "</div>"; }
I’ll keep digging around, but I figured I’d post here first in the meantime… Is there a built-in WP function that would allow me to do this or am I going to have to do a preg_match or something?
Any help provided would be much appreciated
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Extracting a post's gallery shortcode (if it contains one)?’ is closed to new replies.