Title: phimix's Replies | WordPress.org

---

# phimix

  [  ](https://wordpress.org/support/users/phimix/)

 *   [Profile](https://wordpress.org/support/users/phimix/)
 *   [Topics Started](https://wordpress.org/support/users/phimix/topics/)
 *   [Replies Created](https://wordpress.org/support/users/phimix/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/phimix/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/phimix/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/phimix/engagements/)
 *   [Favorites](https://wordpress.org/support/users/phimix/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Get the category id](https://wordpress.org/support/topic/get-the-category-id/)
 *  Thread Starter [phimix](https://wordpress.org/support/users/phimix/)
 * (@phimix)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/get-the-category-id/#post-508579)
 * Great, thanks!
 * It turned out I needed a slightly different function, but with the help of the
   code above I was able to throw something together and put it in category.php
 * function is_in_category($postID, $categoryID) {
    global $wpdb; $sql = “SELECT
   COUNT(post_id) FROM $wpdb->post2cat WHERE post_id = $postID AND category_id =
   $categoryID”; $result = $wpdb->get_var($sql);
 *  if($result > 0)
    { return 1; } else { return 0; } }

Viewing 1 replies (of 1 total)