2

私の the_content フィルターはギャラリーのショートコードを殺しますが、どこに問題があるのか​​ わかりません...空白の the_content フィルターを追加すると、ギャラリーがコンテンツから消え、[gallery]テキストだけが表示されます。the_content フィルターを使用しています:

function test($data){
    echo $data;
}
add_filter('the_content', 'test');

それを修正する方法はありますか?

4

2 に答える 2

3

これはよくある間違いです。新しいフィルターを適用し続けるために情報を返す必要があるだけなので、関数を次のように変更します。

function test($data){
    //apply here any content modification then return new content
    return $data;
}
add_filter('the_content', 'test');

詳細については、http: //codex.wordpress.org/Plugin_API/Filter_Reference/the_contentをご覧ください。

于 2012-05-21T13:49:07.353 に答える