Skip to content


WordPress 特定のページのみコンテンツを表示する

このエントリーをはてなブックマークに追加
はてなブックマーク - WordPress 特定のページのみコンテンツを表示する
Share on Facebook
Post to Google Buzz
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
Share on GREE

Wordpressで特定のページのみコンテンツを表示する方法。

例えば、ホーム(index.php)と固定ページ(page.php)にだけ自己紹介を表示させたい場合。


<?php if (is_home() || is_single()) { ?>
<dl>
<dt>自己紹介♪</dt>
<dd>ましぇたんでっす♪よろしくねん!</dd>
</dl>
<?php } ?>


この「is_home()」や「is_single()」などのfunctionはとても便利に思える。
他にも以下のようなfunctionが用意されている。


s_admin, is_paged, is_archive, is_attachment, is_author, is_category, is_tag, is_comments_popup, is_date, is_day, is_feed, is_home, is_month, is_page, is_plugin_page, is_preview, is_robots, is_search, is_single, is_singular, is_time, is_trackback, is_year, is_404


例えばカテゴリ毎に表示する広告を変えたい場合・・・
・is_category()・・・カテゴリー(is_category(’2′)などとするとカテゴリーIDで絞れる)

超便利。
いいね。

参考:WordPressで特定のページのみコンテンツを表示する方法

関連するかもしれない記事



他のブログも読む

Posted in WordPress.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

*