Using get_field to provide a value to do_shortcode fails for [gallery]
-
Hello,
This was an odd issue, the gist of it is the get_field returns an encoded string which if it’s a shortcode and used within the do_shortcode has unexpected results.
My implementation has a custom field on a custom post which I place a gallery shortcode within and in the php for the page I pull this shortcode out with get_field and process with do_shortcode.
I’m using this for the gallery shortcode specifically.
So populating the field with gallery shortcode – [gallery link="file" columns="1" ids="93,90,89"]
In my PHP I pull this information:
$gallery =get_field(‘gallery_shortcode’);
And process as a shortcode:
echo do_shortcode($gallery);This rendered but the first image of the gallery wasn’t included.
Printing the $gallery shortcode shows the shortcode came through but the do_shortcode failed to render it fully.
- The topic ‘Using get_field to provide a value to do_shortcode fails for [gallery]’ is closed to new replies.