As the article shows, ob_start and ob_get_clean can capture typical loop output and return as a variable. When you’re in the loop you might want to make sure the_content renders it’s shortcode as well.
function do_livecasinoss_shortcode($atts, $content = "") {
// start the buffer
ob_start();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'casino',
'posts_per_page' => 5,
'orderby' => 'date',
'paged' => $paged,
);
$wp_query = new WP_Query($args);
/* PageNavi at Top */
if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();
/* DO STUFF IN THE LOOP */
// run any shortcode items inside the_content
echo apply_filters('the_content', get_the_content());
?>/* Post Loop */<?php
endwhile; endif;
wp_reset_query();
// stop the buffer / capture and return the output
return obj_get_clean();
}
add_shortcode('livecasinoss', 'do_livecasinoss_shortcode');
// Wrapper for livecasinoss shortcode
function do_livecasinos_shortcode($atts, $content = "") {
// return rendered shortcode
return do_shortcode('[livecasinoss]');
}
add_shortcode('livecasinos', 'do_livecasinos_shortcode');