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で特定のページのみコンテンツを表示する方法
関連するかもしれない記事
- WordPress -特定カテゴリのみの最新記事をリスト表示する
- WordPress -My Category Orderプラグイン導入
- WordPress ページナビを表示するWP-PageNaviプラグイン
- すぐに行える内部SEO対策
- WordPress -最新のエントリーに投稿日付を表示する
他のブログも読む



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