2012-03-22 7 views
1

私はそれに渡す文字列にwordpress 'get_excerptフォーマットを適用したいと思います。Wordpressは文字列にフォーマットを適用します。

私は標準的な抜粋がループ内でしか動作しないことを知っていますが、手動で定義していないときに抜粋を生成する関数や何かがあることを期待しています。

答えて

2

を修正答え:

あなたはwp_trim_words()を必要としています。はい、あなたが正しい。 wp_trim_excerpt()は渡された文字列でうまく再生されません。 "私は適用したいと思います[...]"

http://codex.wordpress.org/Function_Reference/wp_trim_words

wp_trim_words("I would like to apply wordpress' get_excerpt format to a string I pass to it. I know the standard excerpt only works within the loop - but I'm hoping there is a function or something I'm missing that generates the excerpt when you don't manually define one.", 5, '[...]');戻り

前の答え:

WordPressは抜粋を生成するwp_trim_excerpt()を使用しています。

http://codex.wordpress.org/Function_Reference/wp_trim_excerpt

おそらく(テキストのソースに応じて)あなたも出力する前にそこにいくつかのフィルタリングをしたいです。

+0

これは機能しません。私は、人々が本質的に機能を再現することをお勧めしています。 http://wordpress.stackexchange.com/questions/6961/using-wp-trim-excerpt-to-get-the-excerpt-outside-the-loop/7400#7400 – mikevoermans

+0

申し訳ありません - 正しくテストしませんでした。今更新されました。 – jamesc

+0

抜粋とまったく同じではない(私が長さの抜粋フィルタなどを適用した場合、それはうまくいくが、それはうまくいく) - ありがとう! – mikevoermans

関連する問題