Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following:

<?php if ( array( 'is_category', 'is_tag' ) ) { ?>

What I want to do is (that doesn't quite work):

<?php if ( array( 'is_category('13')', 'is_tag' ) ) { ?>

So what I'm asking is, how can I include that ID in code that will work? That's how I would do it anywhere outside of an array, so I am unsure exactly how to include it here.

Thanks

share|improve this question
    
What are you actually trying to do. –  Wyck May 16 '12 at 5:40
    
Now you're just checking whether the array is not empty. The whole array(...) part is converted to a boolean. Your current if statement will always return true. –  Geert May 16 '12 at 5:43
2  
@Chris_O & all: Fellas, this question is simple as well as easily answerable by googling. Fair enuff, the OP could have put more effort into it. Also his understanding of PHP is (yet) rather basic, obviously. Nonetheless, why answer it in the comments? Not only do you cheat yourself of possible rep, it undermines SE site mechanics. That's just not good practice, IMHO. See meta –  Johannes Pille May 16 '12 at 6:47
    
Point taken... comment deleted –  Chris_O May 16 '12 at 7:30

1 Answer 1

up vote 0 down vote accepted

As Geert pointed out, your current conditional will always be true. An if() construct needs to be fed an expression. You're feeding it a valid array, so that's true. Always. So far this is basic PHP, regardless of whether in a WP environment or not.

As can be read in Chris_O's comment

if ( is_category('some-cat') && is_tag('some-tag') ) {
    // do something
}

will do the trick.

'some-cat' and 'some-tag' may be the category/tag slug, id or title. The codex page on conditional tags explains the use of these rather well.

share|improve this answer
    
I've finished reading a section of that page and it's helped a lot, thank you –  Phill May 16 '12 at 22:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.