最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

i using this code:

<?php ob_start(); echo '<div class="judul"><h3 style="text-align: center;"><strong>Download <?php echo esc_html( $judul ); ?> Batch Kumpulan Subtitle Indonesia</strong></h3></div>';
echo '<p><div class="deps"><h4>';
echo "<strong>Episode $bepisode</strong></h4>";
echo '</div></p>';
echo '<div class="dfr">';
echo "<strong>$bkualitas</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink</strong><br/><br/>";
echo '</div>';
echo '<div class="dfr">';
echo "<strong>$bkualitas2</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink2</strong><br/><br/>";
echo '</div>';
echo '<div class="dfr">';
echo "<strong>$bkualitas3</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink3</strong><br/><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?

i using this code:

<?php ob_start(); echo '<div class="judul"><h3 style="text-align: center;"><strong>Download <?php echo esc_html( $judul ); ?> Batch Kumpulan Subtitle Indonesia</strong></h3></div>';
echo '<p><div class="deps"><h4>';
echo "<strong>Episode $bepisode</strong></h4>";
echo '</div></p>';
echo '<div class="dfr">';
echo "<strong>$bkualitas</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink</strong><br/><br/>";
echo '</div>';
echo '<div class="dfr">';
echo "<strong>$bkualitas2</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink2</strong><br/><br/>";
echo '</div>';
echo '<div class="dfr">';
echo "<strong>$bkualitas3</strong><br/>";
echo '</div>';
echo '<div class="dln">';
echo "&nbsp;&nbsp;&nbsp;&nbsp;<strong>$blink3</strong><br/><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?

Share Improve this question asked Feb 10, 2017 at 3:55 ArehaAreha 11 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 1

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();
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();

发布评论

评论列表(0)

  1. 暂无评论