- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/get the content
提供: WordPress Codex 日本語版
< 関数リファレンス
投稿のコンテンツ(本文)を取得します。この関数はループ内で使用しなければなりません。
重要:the_content() と異なり、get_the_content() はフィルター 'the_content' を適用せずにコンテンツを返します。すなわち、get_the_content() は動画の自動埋め込みや、ショートコードの展開などを実行しません。
使い方
<?php get_the_content( $more_link_text, $stripteaser ) ?>
パラメータ
- $more_link_text
- (文字列) (オプション) <!--more--> 以降を読むためのリンクとして表示するテキスト。
- 初期値: null - '(さらに…)'
- $stripteaser
- (真偽値) (オプション) <!--more--> 以前の内容を隠すかどうか。
- 初期値: false
- true - <!--more--> 以降のみを表示
- false - 本文をすべて表示 - デフォルト
戻り値
- (文字列)
用例
投稿コンテンツを表示し、必要なら「続きを読む」で終わる
<?php $content = get_the_content( '続きを読む' ); print $content; ?>
参考
下記の関数やグローバル変数を使用します:
- post_password_required()
- get_the_password_form()/en を、post_password_required() が失敗した場合に。
- wp_kses_no_null()/en を、<!--more--> タグの処理中に。
- balanceTags()/en
- get_permalink()
- グローバル変数: $id
- グローバル変数: $post
- グローバル変数: $more
- グローバル変数: $page
- グローバル変数: $pages
- グローバル変数: $multipage
- グローバル変数: $preview
- グローバル変数: $pagenow
コンテンツをフィルターするプラグイン(独自の処理を add_filter( 'the_content' ) で組み込む)を使っていても、この関数は次のように(apply_filters を用いて)自分で呼び出さないとフィルターを適用しない:
<?php apply_filters( 'the_content', get_the_content( $more_link_text, $stripteaser, $more_file ) ) ?>
変更履歴
0.71 : 新規導入
ソースファイル
get_the_content() は wp-includes/post-template.php
にあります。
関連資料
関数リファレンス、テンプレートタグ目次もご覧ください。
最新英語版: WordPress Codex » Function_Reference/get_the_content (最新版との差分)