2011-08-27 21 views
1

是否有可能以某種方式執行/打印WordPress短代碼過濾器中的內容,而不是返回它?我的意思是,短碼功能一般會返回輸出,但不打印。如果我告訴我的短代碼打印功能,它會在所有內容的開始處輸出工作槽短代碼內容,並且我沒有任何可能再使用它。輸出編輯的短代碼內容,不返回它

我真的希望,有人能幫助我,如果someony已經明白了我的意思;)

最好的問候,.wired

回答

1

輕鬆!使用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規則!

+0

我DID考慮緩衝:D但不知何故,我有一個思維錯誤,因爲我認爲我不得不結束短代碼函數內部的緩衝,但在WordPress過濾內容之後。但我錯了,非常感謝你的幫助,謝謝你! –