开发者

Output edited shortcode content, not return it

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜