Title: ankurt's Replies | WordPress.org

---

# ankurt

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

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

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[More Fields] [Plugin: More Fields] Why doesn't this plugin have documentation?](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/)
 *  Thread Starter [ankurt](https://wordpress.org/support/users/ankurt/)
 * (@ankurt)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/#post-3034033)
 * [@alexandruv](https://wordpress.org/support/users/alexandruv/)
 * Yes.
 * The “1” means return a string as opposed to an array.
 * [http://codex.wordpress.org/Function_Reference/get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
 * EDIT: yes, only works inside loop because of get_the_ID(), but you can swap this
   with $post->ID or use any ID you want.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[More Fields] [Plugin: More Fields] Why doesn't this plugin have documentation?](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/)
 *  Thread Starter [ankurt](https://wordpress.org/support/users/ankurt/)
 * (@ankurt)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/#post-3034028)
 * [https://gist.github.com/3717128](https://gist.github.com/3717128)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[More Fields] [Plugin: More Fields] Why doesn't this plugin have documentation?](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/)
 *  Thread Starter [ankurt](https://wordpress.org/support/users/ankurt/)
 * (@ankurt)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-more-fields-why-doesnt-this-plugin-have-documentation/#post-3034027)
 * Yes– I eventually figured it out. I can throw up a quick Gist in a sec…
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Please help me with my "popular categories" code](https://wordpress.org/support/topic/please-help-me-with-my-popular-categories-code/)
 *  Thread Starter [ankurt](https://wordpress.org/support/users/ankurt/)
 * (@ankurt)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/please-help-me-with-my-popular-categories-code/#post-2311863)
 * He he, figured it out. get_posts defaults to showing 5 posts, that’s why!!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Please help me with my "popular categories" code](https://wordpress.org/support/topic/please-help-me-with-my-popular-categories-code/)
 *  Thread Starter [ankurt](https://wordpress.org/support/users/ankurt/)
 * (@ankurt)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/please-help-me-with-my-popular-categories-code/#post-2311636)
 * Ok, guys, turns out getting the post count by counting the number of posts beloning
   to the category is not the way to go. Here’s the working code:
 *     ```
       global $post;
       $categories = get_categories();
       foreach ( $categories as $c ) {
       	$counts[$c->term_id] = $c->count;
       }
       ```
   
 * That gives you a_ $counts_ array populated with category id and count number,
   which you can asort, reverse and slice.
 * Does anyone know _why_ counting the number of posts beloning to a category doesn’t
   give you a proper category count?

Viewing 5 replies - 1 through 5 (of 5 total)