开发者

Output edited shortcode content, not return it

开发者 https://www.devze.com 2023-04-01 09:37 出处:网络
is it possible somehow to execute / print content in a WordPress shortcode filter, not return it? I mean, shortcode functions in general return output, but do not print. If I tell my shortcode f开发者

is it possible somehow to execute / print content in a WordPress shortcode filter, not return it? I mean, shortcode functions in general return output, but do not print. If I tell my shortcode f开发者_开发百科unction to print, it outputs the worked trough shortcode content right in the beginning of all content and I don not have any possibility to work with it any more.

I really hope, someone can help me, if someony has understood what I mean ;)

Best regards, .wired


Easy! Use output buffering.

ob_start(); // content is no longer output but is captured internally
echo 'buffered output'; // business as usual
$output = ob_get_contents(); // pass captured content to variable and
// terminate output buffering (echo beyond this point prints again)
return $output; // or play with it some more

PHP rules!

0

精彩评论

暂无评论...
验证码 换一张
取 消