ob_get_clean(); doesn't return $value in shortcode?

i using this code:

?php ob_start(); echo 'div class="judul"h3 style="text-align: center;"strongDownload ?php echo esc_html( $judul ); ? Batch Kumpulan Subtitle Indonesia/strong/h3/div';
echo 'pdiv class="deps"h4';
echo "strongEpisode $bepisode/strong/h4";
echo '/div/p';
echo 'div class="dfr"';
echo "strong$bkualitas/strongbr/";
echo '/div';
echo 'div class="dln"';
echo "nbsp;nbsp;nbsp;nbsp;strong$blink/strongbr/br/";
echo '/div';
echo 'div class="dfr"';
echo "strong$bkualitas2/strongbr/";
echo '/div';
echo 'div class="dln"';
echo "nbsp;nbsp;nbsp;nbsp;strong$blink2/strongbr/br/";
echo '/div';
echo 'div class="dfr"';
echo "strong$bkualitas3/strongbr/";
echo '/div';
echo 'div class="dln"';
echo "nbsp;nbsp;nbsp;nbsp;strong$blink3/strongbr/br/";
echo '/div'; $out = ob_get_clean(); ?

then using this code in single.php :

?php echo do_shortcode( '[restabs alignment="osc-tabs-center" responsive="false" tabcolor="#c1c1c1" tabheadcolor="#0a0a0a" seltabcolor="#8c8c8c" seltabheadcolor="#ffffff" tabhovercolor="#8c8c8c"  responsive="true" icon="true" text="More"][restab title="Link Batch" active="active"]' . $out . '[/restab][/restabs]' );?

why there is no meta value output?

but without using ob_get_clean(); and shortcode, i can get output like this :

does ob_get_clean(); clear all $value? or $value doesn't work with shortcode?

Topic tabs shortcode metabox Wordpress

Category Web


function id_shortcode() {
    ob_start();
?>
<HTML> <here> ... 
<?php
    return ob_get_clean();
} ?>

  

If have query in shortcode don't foget wp_reset_postdata(); after return ob_get_clean();


You don't see anything because you're assigning the content to $out but then you don't do anything with that value. Shortcodes have to return their content or you won't see any output.

$out = ob_get_clean();
return $out;

or just

return ob_get_clean();

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.