There is a site on wordpress . On one of the pages I want to put one shortcode into another here with this entry:

 <?php echo do_shortcode('[spoiler name="ФОРМА ЗАЯВКИ" ][contact-form-7 id="36762" title="Форма-заявка"][/spoiler]'); ?> 

but, the first one works, and the second with contact-form-7 is not. Separately, both work. Why and how can this be fixed?

    2 answers 2

    To use nested shortcodes, the external shortcode function must call do_shortcode($content); .

     add_shortcode( 'my_shortcode', 'my_shortcode_fn' ); function my_shortcode_fn($atts, $content){ echo do_shortcode($content); } 

    See the spoiler shortcode code.

      @Ponio is much simpler - just write down this structure:

       <?php $form = do_shorcode('[contact-form-7 id="36762" title="Форма-заявка"]'); echo do_shortcode('[spoiler name="ФОРМА ЗАЯВКИ" ]'.$form.'[/spoiler]'); ?>