ankurt
Forum Replies Created
-
Yes.
The “1” means return a string as opposed to an array.
http://codex.ww.wp.xz.cn/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.
Yes– I eventually figured it out. I can throw up a quick Gist in a sec…
Forum: Fixing WordPress
In reply to: Please help me with my "popular categories" codeHe he, figured it out. get_posts defaults to showing 5 posts, that’s why!!
Forum: Fixing WordPress
In reply to: Please help me with my "popular categories" codeOk, 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?