My suspicion is that, for some reason, the name
“51m series” or slug
51m-series
is (or both are) matching is_category( 51 )
.
The is_category()
function uses the PHP in_array()
conditional to match against ID, slug, and name:
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;
The in_array()
conditional appears to be returning true when 51
is found in the name/slug 51m series
/51m-series
. While both the name and slug conditional checks should be case-sensitive, none of the checks are strict. So the integer 51
is possibly being evaluated as a string against $cat_obj->name
, and matching 51m Series
(or against $cat_obj->slug
, and matching 51m-series
)
Possible solutions:
- Use category names/slugs that don’t begin with numbers
- Query explicitly against category slugs rather than against category IDs
This may also be a case where core needs to perform a strict
check in in_array()
, to differentiate between an ID integer and a name/slug string.