wordpress - Working with nested recursive shortcodes -
i have these 2 functions:
add_shortcode('section_block_container','dos_section_block_container'); function dos_section_block_container($atts, $content = null) { $content = do_shortcode($content); echo '<ul class="list-unstyled list-inline">' . $content . '</ul>'; } add_shortcode('section_block','dos_section_blocks'); function dos_section_blocks($atts, $content = null) { // define attributes , defaults extract( shortcode_atts( array ( 'first' => false, 'color' => '', 'icon' => '', 'title' => '', ), $atts ) ); ?> <li> <a href="" style="background-color: <?php echo $color; ?>" title="<?php echo $title; ?>" class="section-block show-grid col-12 col-sm-3 <?php // echo ($first == true ? 'col-offset-3 ' : '') ?>col-lg-3"> <h4><?php echo strip_tags ($title); ?></h4> <?php echo strip_tags($content); ?> <?php echo $icon; ?> </a> </li> <?php }
and in wp editor recursive [section_block]
[section_block_container]
[section_block color="#001e61" title="lorem ipsum" icon="" first="true"][/section_block]
[section_block color="#001e61" title="lorem ipsum" icon="" first="true"][/section_block]
[/section_block_container]
the problem the list not appear inside container outside do_shortcode();
a shortcode cannot echo
value.
has return
it.
see shortcode_api , do_shortcode
documentation.
Comments
Post a Comment