Return to Snippet

Revision: 21218
at December 9, 2009 04:11 by LuckyShot


Updated Code
<?php


if ( in_category('News') ) {
  // belongs to cat
}

// or array
if ( in_category(array('News', 'Tools')) ) {
  // belongs to one or more of the categories
}

Revision: 21217
at December 7, 2009 04:50 by LuckyShot


Initial Code
<?php

if ( in_category('News') ) {

}

// or array

if ( in_category(array('News', 'Tools')) ) {

}

Initial URL
http://codex.wordpress.org/Function_Reference/in_category

Initial Description


Initial Title
Wordpress - Check if posts belongs to a category

Initial Tags
post, wordpress, category

Initial Language
PHP