2017-10-25 15 views
1

特定のページテンプレートから子テーマ機能を除外する必要があります。複数のページテンプレートを除外する

私は声明を除外するために、より多くのページテンプレートを追加するにはどうすればよいこの

if (!(is_page_template('templates/my_page_template.php'))) 
{ // the child theme function here 
.... 
} 

のような1つのテンプレートを除外することができますか?

+0

場合{} – Stender

+0

だけ(is_page_template( 'テンプレート/ my_page_template.php')&& is_page_template( 'テンプレート/ my_page_template2.php')!!)余分な条件を追加する - またはいくつかの場合は、switch文を作成します。 – Stender

答えて

2
if (
    !(
    (is_page_template('templates/my_page_template.php')) or 
    (is_page_template('templates/my_page_template1.php')) or 
    (is_page_template('templates/my_page_template2.php')) or 
    (is_page_template('templates/my_page_template3.php')) or 
    ) 

) 
{ // the child theme function here 
.... 
} 
1

is_page_template関数は、引数として配列を受け入れます。ここを参照してください:https://developer.wordpress.org/reference/functions/is_page_template/

あなたのような何かを行うことができます:

if (! (is_page_template(array('templates/my_page_template.php', 'templates/my_page_template2.php')))) 
{ // the child theme function here 
    .... 
} 
関連する問題