Title: is_category() ISSUE &amp; REQUEST
Last modified: August 19, 2016

---

# is_category() ISSUE & REQUEST

 *  [jtlowe22](https://wordpress.org/support/users/jtlowe22/)
 * (@jtlowe22)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/is_category-issue-amp-request/)
 * I am experiencing an issue with two categories:
 * Name: 3-d
    slug: 3-d id: 42
 * Name: Illustration-folio
    slug: illustration-folio id: 3
 * When I am on a category archive page and ‘3-d’ is the category, ‘is_category(
   42)’ and ‘is_category(3)’ evaluate to true.
 * It would be nice to have separate functions for the type of category information
   being entered. For example, a function that only takes the category id. Or be
   able to accept arguments.
 * If my issue is a result of me doing something incorrectly, please let me know.
 * Thanks,
    Jordan

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

 *  Thread Starter [jtlowe22](https://wordpress.org/support/users/jtlowe22/)
 * (@jtlowe22)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/is_category-issue-amp-request/#post-1354877)
 *     ```
       function is_category ($category = '')
        {
            ...
             if ( in_array( $cat_obj->term_id, $category ) )
                 return true;
             elseif ( in_array( $cat_obj->name, $category ) )
                 return true;
             elseif ( in_array( $cat_obj->slug, $category ) )
                 return true;
             ...
         }
       ```
   
 * What I believe is happening is that when cat_id ‘3’ is not found in ’42’ it looks
   for ‘3’ in the current category name. Since it only looks for 3 anywhere in the
   $category variable, it finds 3 in 3-d evaluates this to true.
 * I will look into this. Does anyone have suggestions?
 * Thanks,
    Jordan
 *  Thread Starter [jtlowe22](https://wordpress.org/support/users/jtlowe22/)
 * (@jtlowe22)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/is_category-issue-amp-request/#post-1354885)
 * This is also an inconvenience when you use is_category(cat_name) for a category
   name that shares a string with a similar category name. For example.
 * using is_category(‘category’) evaluates to true when on the archive page having‘
   category12’ as its name.
 *  Thread Starter [jtlowe22](https://wordpress.org/support/users/jtlowe22/)
 * (@jtlowe22)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/is_category-issue-amp-request/#post-1354891)
 * can check for both:
 *     ```
       if(is_category($cat_name) && is_category($cat_id)){
           ...
       }
       ```
   

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

The topic ‘is_category() ISSUE & REQUEST’ is closed to new replies.

## Tags

 * [is_category](https://wordpress.org/support/topic-tag/is_category/)
 * [problem](https://wordpress.org/support/topic-tag/problem/)
 * [request](https://wordpress.org/support/topic-tag/request/)

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 3 replies
 * 1 participant
 * Last reply from: [jtlowe22](https://wordpress.org/support/users/jtlowe22/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/is_category-issue-amp-request/#post-1354891)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
