is_single() – WordPress テンプレートタグのリファレンス
シングル投稿ページが表示されている場合です。
When any single Post page is being displayed.
is_single(’17′)
投稿17がシングル投稿として表示されている場合です。
When Post 17 is being displayed as a single Post.
is_single(‘Irish Stew’)
“Irish Stew”タイトルの投稿がシングル投稿として表示されている場合です。
When the Post with Title “Irish Stew” is being displayed as a single Post.
is_single(‘beef-stew’)
投稿スラッグ”beef-stew”の投稿がシングル投稿として表示されている場合です。
When the Post with Post Slug “beef-stew” is being displayed as a single Post.
is_single(array(17,’beef-stew’,’Irish Stew’))
シングル投稿が投稿ID17、post_nameが”beef-stew”、post_titleが”Irish Stew”のいずれか表示されている時にtrueを返します。
Returns true when the single post being displayed is either post ID 17, or the post_name is “beef-stew”, or the post_title is “Irish Stew”.
is_single(array(17, 19, 1, 11))
シングル投稿が記事ID17、記事ID19、記事ID1、記事ID11のいずれか表示された時にtrueを返します。
Returns true when the single post being displayed is either post ID 17, post ID 19, post ID 1, or post ID 11.
is_single(array(‘beef-stew’, ‘pea-soup’, ‘chili’))
シングル投稿が、post_name”beef-stew”、post_name”pea-soup”、post_name”chili”のいずれか表示された時にtrueを返します。
Returns true when the single post being displayed is either the post_name “beef-stew”, post_name “pea-soup” or post_name “chili”.
is_single(array(‘Beef Stew’, ‘Pea Soup’, ‘Chili’))
投稿記事がpost_title “Beef Stew”、post_title “Pea Soup”、post_title “Chili”のいずれか表示された時にtrueを返します。
Returns true when the single post being displayed is either the post_title “Beef Stew”, post_title “Pea Soup” or post_title “Chili”.
注:配列の機能はバージョン2.5で追加されました。この関数は、投稿ID名、投稿タイトル、投稿名の間に区別されません。”17″という名付けられた投稿は、もし投稿IDの17が要求された場合に表示されます。恐らく、スラッグ”17″と投稿の保持する事と同じです。
Note: The array ability was added at Version 2.5. This function does not distinguish between the post ID, post title, or post name. A post named “17″ would be displayed if a post ID of 17 was requested. Presumably the same holds for a post with the slug “17″.
作業例
この例では、いくつかの特定シングル投稿ページを表示している時のみ表示するためにis_single()を使用するための方法を表示しています。
This example shows how to use is_single() to display something specific only when viewing a single post page:
if (is_single()) {
echo 'This is just one of many fabulous entries in the ' . single_cat_title() . ' category!';
}
その他の例では、ループに条件タグを使用する方法です。これがシングル投稿、カテゴリー、ホームとページで表示する固定のアーカイブの時、index.php内で、コンテンツあるいは抜粋を表示する選択をします。
Other example how to use Conditional Tags into loop. choose display content or excerpt in the index.php, when this is unique archive for display single post, categories, home and page.
if (is_home() || is_single()) {
the_content();
}
else {
the_excerpt();
}
Tags:WordPress テンプレートタグ パーマリンクタグ リファレンス 条件タグ
ツイート
New記事投稿!: is_single() http://lovelog.eternal-tears.com/tmp-tag/condition/is_single/
ブログ更新: is_single() – http://tinyurl.com/y5r8hxl