• サイトデザイン工事中です。ご意見をお寄せください
  • 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

テンプレートタグ/the content

提供:WordPress Codex 日本語版
移動: 案内, 検索


このページ「テンプレートタグ/the content」は以下未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。(上の説明とマージしつつ翻訳?そのまま残した方が簡潔で見やすい?)

目次

説明

Displays the contents of the current post. This tag must be within The Loop.

If the quicktag <!--more--> is used in a post to designate the "cut-off" point for the post to be excerpted, the_content() tag will only show the excerpt up to the <!--more--> quicktag point on non-single/non-permalink post pages. By design, the_content() tag includes a parameter for formatting the <!--more--> content and look, which creates a link to "continue reading" the full post.

Note about <!--more--> :
  • No whitespaces are allowed before the "more" in the <!--more--> quicktag. In other words <!-- more --> will not work!
  • The <!--more--> quicktag will not operate and is ignored in テンプレート, such as single.php, where just one post is displayed.
  • Read Customizing the Read More/en for more details.

使い方

<?php the_content( $more_link_text, $strip_teaser, $more_file ); ?>

How to pass parameters to tags with PHP function-style parameters

パラメータ

$more_link_text
文字列)(オプション) The link text to display for the "more" link. 初期値は '(more...)'
$strip_teaser
論理値)(オプション) Should the text before the "more" link be hidden (TRUE) or displayed (FALSE). 初期値はFALSE
$more_file
文字列)(オプション) File the "more" link points to (no longer used). 初期値は The current file

Examples

Designating the "More" Text

Displays the content of the post and uses "Read more..." for the more link text when the <!--more--> Quicktag is used.

<?php the_content('Read more...'); ?>

Include Title in "More"

Similar to the above example, but thanks to the_title() tag and the display parameter, it can show "Continue reading ACTUAL POST TITLE" when the <!--more--> Quicktag is used.

<?php the_content("Continue reading " . the_title('', '', false)); ?>

Overriding Archive/Single Page Behavior

If the_content() isn't working as you desire (displaying the entire story when you only want the content above the <!--more--> Quicktag, for example) you can override the behavior with global $more.

<?php 
global $more;    // Declare global $more (before the loop).
$more = 0;       // Set (inside the loop) to display content above the more tag.
the_content("More...");
?>

if you need to display all of the content:

<?php 
global $more;    // Declare global $more (before the loop).
$more = 1;       // Set (inside the loop) to display all content, including text below more.
the_content();
?>

Alternative Usage

You may use get_the_content()/en to return the content value instead of outputting it directly. Example:

<?php $content = get_the_content(); ?>

Please note! get_the_content/en will not have the following done to it and you are advised to add them until the core has been updated:

<?php
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
?>

Changelog

Since: 0.71

Source File

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

最新英語版: WordPress Codex » Template Tags/the_content最新版との差分

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, wp_link_pages, next_post_link, next_posts_link, previous_post_link, previous_posts_link, posts_nav_link, sticky_class, the_meta

個人用ツール
名前空間
変種
操作
このサイトについて
特集
サーバ別情報
リファレンス
ドキュメント整備
ツールボックス
他の言語