ページを検出するために使用できるワードプレス機能はありますか? 私がやりたいことの例は以下のとおりです。
<?php if( is_FUNCTION_page('Contact Us') ) : ?>
...display this <div> / xhtml
<?php else: ?>
something else <div>
<?php endif;?>
is_page()関数を確認します。
is_page();
// When any single Page is being displayed.
is_page(42);
// When Page 42 (ID) is being displayed.
is_page('Contact');
// When the Page with a post_title of "Contact" is being displayed.
is_page('about-me');
// When the Page with a post_name (slug) of "about-me" is being displayed.
is_page(array(42,'about-me','Contact'));
// Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact". Note: the array ability was added at Version 2.5.
うん。これを行うには、 Wordpressの is_page関数を使用します。
例:
<?php if( is_page('Contact Us') ) : ?>
<div> Your If content goes here </div>
<?php else: ?>
<div> something else </div>
<?php endif;?>
ノート:
ループ内では使用できません
ループ中に特定のグローバル変数が上書きされるため、 is_page() は機能しません。ループの後に使用するには、ループの後に wp_reset_query() を呼び出す必要があります。