Category count wrong
-
Your code was not returning a correct category count on the category page. I have changed your code to fix it.
Here is your original code:
$travelera_cat = get_the_category(); $travelera_cat = $travelera_cat[0]; $travelera_cat_count = $travelera_cat->category_count; printf( _n( '%s Article', '%s Articles', intval( $travelera_cat_count ), 'travelera-lite' ), intval( $travelera_cat_count ) );
And here is code that works:
$idObj = get_category_by_slug(single_cat_title( '', false )); $thisid = $idObj->term_id; $travelera_cat = get_category($thisid); $travelera_cat_count = $travelera_cat->count; printf( _n( '%s Article', '%s Articles', intval( $travelera_cat_count ), 'travelera-lite' ), intval( $travelera_cat_count ) );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Category count wrong’ is closed to new replies.