- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
プラグイン API/フィルターフック一覧/get the excerpt
説明
"get_the_excerpt" filter is used to filter the excerpt of the post after it is retrieved from the database and before it is returned from
The "get_the_excerpt" filter is used to filter the excerpt of the post after it is retrieved from the database and before it is returned from the get_the_filter() function.
使い方
When the 'get_the_excerpt' filter is called, it is passed a single argument containing the post excerpt.
function filter_function_name( $excerpt ) { # ... } add_filter( 'get_the_excerpt', 'filter_function_name' );
Where 'filter_function_name' is the function WordPress should call when the excerpt is being retrieved. Note that the filter function must return the excerpt after it is finished processing, or page sections showing an excerpt will be blank, and other plugins also filtering the excerpt may generate errors.
filter_function_name should be unique function name. It cannot match any other function name already declared.
用例
「続きを読む」リンクのカスタム化
This example from the twentyeleven theme appends a custom "Read more" link to post excerpts. See has_excerpt() and is_attachment()
/** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. */ function twentyeleven_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= twentyeleven_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
参考資料
最新英語版: WordPress Codex » Plugin API/Filter Reference/get the excerpt (最新版との差分)