1

是否有可能以某种方式在 WordPress 短代码过滤器中执行/打印内容,而不是返回它?我的意思是,短代码函数通常返回输出,但不打印。如果我告诉我的简码函数进行打印,它会在所有内容的开头输出工作的简码内容,我再也没有任何可能使用它了。

我真的希望,如果有人理解我的意思,有人可以帮助我;)

最好的问候, .wired

4

1 回答 1

1

简单的!使用输出缓冲

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规则!

于 2011-08-27T21:31:03.747 回答