{"id":11636692,"date":"2019-06-14T04:18:20","date_gmt":"2019-06-14T04:18:20","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/category-count-wrong\/"},"modified":"2019-06-14T04:18:20","modified_gmt":"2019-06-14T04:18:20","slug":"category-count-wrong","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/category-count-wrong\/","title":{"rendered":"Category count wrong"},"content":{"rendered":"<p>Your code was not returning a correct category count on the category page. I have changed your code to fix it.<\/p>\n<p>Here is your original code:<\/p>\n<pre><code>$travelera_cat = get_the_category();\n$travelera_cat = $travelera_cat[0];\n$travelera_cat_count = $travelera_cat-&gt;category_count;\nprintf( _n( &#039;%s Article&#039;, &#039;%s Articles&#039;, intval( $travelera_cat_count ), &#039;travelera-lite&#039; ), intval( $travelera_cat_count ) );<\/code><\/pre>\n<p>And here is code that works:<\/p>\n<pre><code>$idObj = get_category_by_slug(single_cat_title( &#039;&#039;, false )); \n $thisid = $idObj-&gt;term_id;\n $travelera_cat = get_category($thisid);\n $travelera_cat_count = $travelera_cat-&gt;count;\n printf( _n( &#039;%s Article&#039;, &#039;%s Articles&#039;, intval( $travelera_cat_count ), &#039;travelera-lite&#039; ), intval( $travelera_cat_count ) );<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-11636692","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11636692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11636692\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11636692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}