Specific loop in Shortcode

Ok mate – i got you…
you should really break into 2 shortcodes. One as a wrapper (which is really short) and the other for the content…

Example:

add_shortcode('servicewrap', 'service_wrapsc');
function service_wrapsc($atts, $content = null) {
    return '<div class="service"><div class="container"><div class="row">'.do_shortcode($content).'</div></div></div>';
}


add_shortcode('servicesingle', 'service_singlesc');
function service_singlesc($atts, $content = null) {

    extract(shortcode_atts(array(
        'icon'  => 'fa-briefcase'
    ), $atts));


    return '
    <div class="col-md-3 col-sm-6">';
        <div class="service-icon wow animated fadeInDown" data-wow-delay="300ms"><i class="fa '.$icon.'"></i></div>
        <div class="text wow animated fadeInUp" data-wow-delay="300ms">
            <p>'.do_shortcode($content).'</p>
        </div>
    </div>';
}

Than… You can do something like

[servicewrap]
    [servicesingle icon=""]Your title here[/servicesingle]
    [servicesingle icon=""]Your title here[/servicesingle]
    [servicesingle icon=""]Your title here[/servicesingle]
[/servicewrap]

Leave a Comment