Bjarne
Bjarne

Reputation: 11

How to combine two different conditional tags on Wordpress Plugin Widget-Logic?

How can I combine two different conditional tags on Wordpress Plugin Widget-Logic? How to combine page and single-post in one conditional tag or in one widget?

For example I tried:

!is_page(9) ) || !is_single(10)

But it does not work. Does anybody know a solution?

Thanks Best Regards

Upvotes: 1

Views: 560

Answers (3)

Bjarne
Bjarne

Reputation: 11

O.k. it works like this

!is_page( array( 1,2,3,4,5) ) && !is_single( array( 6,7,8,9,10) )

Upvotes: 0

Bjarne
Bjarne

Reputation: 11

thanks.

And how would be the correct syntax here?

!is_page( array( 1,2,3,4,5) || !is_single( array( 6,7,8,9,10) )

I get a parse error

Thanks a lot

Upvotes: 0

Dario
Dario

Reputation: 2723

Well, the code you posted cannot work because it has unbalanced parentheses.

!is_page(9) || !is_single(10)

is what you mean. However, I doubt that it is what you want, because it is enough that one of the two predicates is true for the whole OR expression to be true, and the two predicates will never be simultaneously false (you will never be on page 9 and post 10 at the same time!): your expression will always evaluate true.

I suspect that what you want is that your widget appears on all pages except page 9 and on all posts except post 10. This would be coded as

!is_page(9) && !is_single(10)

or (if this is easier to understand)

!(is_page(9) || is_single(10))

Both will work.

Upvotes: 1

Related Questions