Ian
Ian

Reputation: 865

WordPress conditional tags for if it's home or array of pages

Trying to display content only on pages that aren't the homepage or a specific few pages of the site. Using the following but it is displaying the message on the home and pages I don't want it to:

<?php
if ( !is_home() || !is_page( array(14,15,94,118,285)) ) { ?>

<div id="message">
<p>Hey this is my message.</p>
</div>

<?php } 

?>

What am I doing wrong gang?

Upvotes: 0

Views: 1405

Answers (1)

Steve Ray
Steve Ray

Reputation: 158

I think you want an AND operator (&&) instead of an OR (||) in your IF statement.

Your IF statement will evaluate as true if either a) it's not the home page, or b) it's not one of the pages in your array. Which means it will evaluate as true all the time (except in the case where the home page is included in the array, in which case it won't be true for the home page).

Upvotes: 1

Related Questions