Including Shortcode Within a Figure
-
Hey Micah,
On my new ‘lil Pokemon site, I’m trying to add a call to Widgets on Pages Shortcode within the figure generated by mPress. I’d like to be able to put responsive objects on both the left and right of the central random image found within the iFrame (you can see an example of this when you click the “eevolve” button on the homepage). Because the
figure
is displayed as a block, I’d like to float these widget sidebars within the same div (and as a result, the same figure).I’ve made two widgets with WOP and put some filler text. I titled them “Sidebar1_Left” and “Sidebar2_Right.” The correct shortcodes for these two widgets are:
[widgets_on_pages id=”Sidebar1_Left”]
&
[widgets_on_pages id=”Sidebar2_Right”],respectively.
I tried to simply insert these into the plugin between the <figure> tags using the php echo do_shortcode function:
if ( $display_caption ) { $image_html = "<figure> <?php echo do_shortcode('[widgets_on_pages id="Sidebar1_Left"]'); ?> {$image_html}<figcaption>{$image->post_excerpt}</figcaption> <?php echo do_shortcode('[widgets_on_pages id="Sidebar2_Right"]'); ?> </figure>"; }
…but that broke the site with a T-String error.
And so I’m stumped! Could you advise either the 1) correct place for me to put this code or 2) an alternate approach to solving the puzzle?
Thanks so much!
-NS
- The topic ‘Including Shortcode Within a Figure’ is closed to new replies.