WordPress.org

Support

Support » How-To and Troubleshooting » how do I use the “category ID” variable in a conditional?

how do I use the “category ID” variable in a conditional?

  • I’m looking to put a conditional argument on my index.php that’d look something like this:

    if $categoryid = 1 {
    echo post template #1;
    }
    if $categoryid = 2 {
    echo post template #2;
    }

    et cetera. My problem is: I don’t know what the variable for category id is. I’ve tried many different variable names; perhaps I simply don’t know how to globalize it. I’ve been trying things like $variable and $post[‘variable’] and nothing will parse. Any insight into this matter will be greatly appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘how do I use the “category ID” variable in a conditional?’ is closed to new replies.