user3763262
user3763262

Reputation: 3

Wordpress PHP multiple else statements

I am making a wordpress theme and i want to have some of the page templates with an extended header div tag so i can add extra things in.

This is the code i have:

<?php if (!is_page_template('page-homepage.php')) { echo "</div>"; } ?>

I want it so i can have alternatives to the page-homepage.php so for example page-team.php as i want that individual page template to not close the div yet either, i tried writing this but it just does every page:

<?php if (!is_page_template('page-homepage.php' or 'page-team.php')) { echo "</div>"; } ?>

Any ideas? My php skills are not very advanced!

thanks :D

Upvotes: 0

Views: 169

Answers (1)

Gergo Erdosi
Gergo Erdosi

Reputation: 42063

You are making a logical operation on two strings ('page-homepage.php' or 'page-team.php') which evaluates to true, so the statement becomes:

<?php if (!is_page_template(true)) { echo "</div>"; } ?>

Try this instead:

<?php if (!is_page_template('page-homepage.php') && !is_page_template('page-team.php')) { echo "</div>"; } ?>

Upvotes: 2

Related Questions