Only show content if current page is NOT one of 2 page templates

I’ve been using this if conditional statement to only show content if the current page is NOT using a certain page template;

if (! is_page_template('template-custom.php')) {
    <!-- show some content  -->
}

which has been working fine. Only now I need to amend the statement to show content if the current page is NOT using one of 2 templates (So if the current page uses template-custom.php or template-custom2.php do NOT show the content).

Read More

I tried this;

if (! is_page_template('template-custom.php') || is_page_template('template-custom2.php')) {
    <!-- show some content  -->
}

and this;

if (! is_page_template('template-custom.php') || ! is_page_template('template-custom2.php')) {
    <!-- show some content  -->
}

but to no avil.

Any suggestions?

Related posts

3 comments

  1. If you want don’t want to show content if the current template is template-custom.php or template-custom2.php you can use:

    if (!is_page_template('template-custom.php') && !is_page_template('template-custom2.php')) {
        <!-- show some content when you AREN NOT in template-custom.php NOR template-custom2.php -->
    }
    

    or

    if (is_page_template('template-custom.php') || is_page_template('template-custom2.php')) {
        <!-- show some content when you ARE in template-custom.php OR template-custom2.php -->
    }
    
  2. try this:

    if (! is_page_template('template-custom.php') || ! is_page_template('template-custom2.php')) {
        <!-- show some content  -->
    }
    

Comments are closed.