Title: A quick hand (PHP IF)
Last modified: August 18, 2016

---

# A quick hand (PHP IF)

 *  [amiantos](https://wordpress.org/support/users/amiantos/)
 * (@amiantos)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/)
 * I’m trying to rid up a simple script in my category template that will first 
   check to see if it’s a category page, then check the ID of the category and then
   parse in a description based on the ID of the category. For whatever reason, 
   I got the first part right, but I can’t get the second part right. I can’t find
   any pages through google really detailing what I’m doing wrong so I figured I’d
   ask here.
 * `<?php if (is_category()) : ?>
    <div class="cat-desc">
 *  <?php if (single_cat_title() == "General") : ?>
    (This is where the description
   goes for the General category) <?php endif; ?>
 * </div>
    <?php endif; ?>
 * Where am I going wrong? This “works” but all it does is, instead of displaying
   the description, it displays the name for the categories.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [dissurion](https://wordpress.org/support/users/dissurion/)
 * (@dissurion)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/#post-130663)
 * I’m not sure but single_cat_title is a function, so that will not work. Alternatively
   you could try the_category_ID(), which according to the template reference is
   static data.
 *  Thread Starter [amiantos](https://wordpress.org/support/users/amiantos/)
 * (@amiantos)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/#post-130697)
 * Thanks, I’ll try that
 *  Thread Starter [amiantos](https://wordpress.org/support/users/amiantos/)
 * (@amiantos)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/#post-130698)
 * Oh, I don’t think that will work. Anyone else have any tips? It’s got to be possible…
   some how. I tried assigning the function’s output to a variable and then using
   the variable in the IF, but that didn’t work either.
 *  [dissurion](https://wordpress.org/support/users/dissurion/)
 * (@dissurion)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/#post-130966)
 * The function already is a constant, eg the_category_ID() is 1 for the category
   general (if you left it that way).
    Maybe this is easier: if ($_GET[‘cat’] ==“
   1”) That should work also.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘A quick hand (PHP IF)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [dissurion](https://wordpress.org/support/users/dissurion/)
 * Last activity: [21 years, 5 months ago](https://wordpress.org/support/topic/a-quick-hand-php-if/#post-130966)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
