Shortcode or PHP inside a shortcode in WordPress

On a php page in wordpress, I have a shortcode for an accordion, that consists of the following, and works perfectly:

<?php echo do_shortcode('[su_accordion]
[su_spoiler title="Feature Locations" style="fancy"] CONTENT GOES HERE
[/su_spoiler]
[/su_accordion]'); ?>

Within the accordion, I want to display an interactive map, which can be displayed using either a shortcode, or PHP. Both options are:

Read More
[show-map id='1'], or
<?php build_i_world_map(1); ?>

When I insert either of these into the accordion shortcode, the map does not display. However, outside of the accordion, the second option above (with php) displays successfully.

What am I missing in terms of including this in the shortcode for the accordion?

Related posts

2 comments

  1. In your example your outer section should be like

    <?php echo do_shortcode('[su_accordion]
    [su_spoiler title="Feature Locations" style="fancy"]'. build_i_world_map(1) .'
    [/su_spoiler]
    [/su_accordion]'); ?>
    

    In wordpress you should call do_shortcode() for shortcode calls.

    <?php echo do_shortcode("[show-map id='1']"); ?>
    

    do_shortcode() reference

  2. this is an effective way to include a concatenating inside a shortcode function

    <?php echo do_shortcode('[download url='.$next_attachment_url.']'); ?>
    

Comments are closed.