• I want some section of code not to display if the page is one of two page templates so I try:

    <?php if(!is_page_template('temp1.php') || !is_page_template('temp2.php')){ ?>
    <h1>Test</h1?
    <?php } ?>

    But it doesn’t work, however if I do one individually then it works as expected? I’m guessing i’m constructing it wrong but can’t point it out?

Viewing 2 replies - 1 through 2 (of 2 total)
  • try && ( AND )

    <?php if(!is_page_template('temp1.php') && !is_page_template('temp2.php')){ ?>
    <h1>Test</h1?
    <?php } ?>

    (assuming that the ‘is_page_template()’ part is ok)

    if you have trouble with boolean calculations, making a table with all possible permutations might help:

    t1  t2  !t1 !t2  ||  &&
    -------------------------
     0   0   1   1    1   1
     1   0   0   1    1   0
     0   1   1   0    1   0
     1   1   0   0    0   0
    Thread Starter xdesi

    (@xdesi)

    Thanks a lot alchymyth for your help, && was exactly what I needed.

    Now I look at it I see where I went wrong, I think I was reading || as:

    IF the page isn’t temp1 OR temp2 then you can display the following code…

    rather than:

    IF the page isn’t temp1 OR isn’t temp2 then you can display the following code…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Simple WP Conditional Help’ is closed to new replies.