Reputation: 11
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
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
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
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