get_the_excerpt

Sponsored Link

変数への代入のための投稿抜粋を返します。このタグはループ内になければなりません。
抜粋して印刷したい場合には、the_excerpt()を使用することをお勧めします。

Sponsored Link

Returns the post excerpt for assignment to a variable. This tag must be within The Loop.
If you only wish to print the excerpt you may prefer to use the_excerpt().

get_the_excerptのファンクションタグ使用方法

< ?php $excerpt = get_the_excerpt( $deprecated ) ?>

get_the_excerptのパラメーター

$deprecatedは必須ではありません。

$deprecated is not required.

戻り値

投稿に抜粋がない場合、最後に”[…]”で空の文字列を返します。
パスワード保護されたページの場合には、”これは保護された投稿なので、抜粋はありません。”のデフォルト値である文字列を返します。このテキストは関数定義で変更することができます。
ポストが抜粋されて、パスワードで保護されていない場合、文字列として抜粋を返します。

If the post does not have an excerpt, it returns an empty string, with “[…]” at the end.
For password protected pages it returns a string, which has a default value of “There is no excerpt because this is a protected post.” This text can be changed in the function definition.
If the post has an excerpt and is not password protected, it returns the excerpt as a string.

get_the_excerpt()は、ページに抜粋を出力せずに、変数内の値を取得および格納するために使用することができます。

get_the_excerpt() can be used to retrieve and store the value in a variable, without outputting it to the page.

<?php
$myExcerpt = get_the_excerpt();
if ($myExcerpt != '') {
// Some string manipulation performed
}
echo $myExcerpt; // Outputs the processed value to the page
?>

文字の最大数を指定することによって、抜粋を出力するためにget_the_excerpt()を使用してください。

Use get_the_excerpt() to print an excerpt by specifying a maximium number of characters.

$charlength) {
$subex = substr($excerpt,0,$charlength-5);
$exwords = explode(” “,$subex);
$excut = -(strlen($exwords[count($exwords)-1]));
if($excut<0) { echo substr($subex,0,$excut); } else { echo $subex; } echo "[...]"; } else { echo $excerpt; } }[/php]

ソースファイル

get_the_excerpt()は、wp-includes/post-template.php内に位置しています。

get_the_excerpt() is located in wp-includes/post-template.php.

関連ファンクションタグ

the_excerpt()

Sponsored Link