Help with wordpress code for reddit's 'what's hot'
-
Hi all, I’m struggling with the following piece of code and was wondering whether anyone could help me.
For my site (which only has upvotes) this is how I’ve defined the what’s hot algorithm, for reference see http://amix.dk/blog/post/19588:
hot= (log10($votes))+(ts/45000); where ts=time post was submitted minus 7:46:42 a.m. December 8, 2005 in seconds and $votes = get_post_meta ($post->ID, BM_META_VOTES, true);So if I want to just order by votes in my query statement i set orderby to ‘meta_value_num’ and meta_key to ‘BM_META_VOTES’. My question is to implement the above which of the following methods should/can I use:
$query = array ( 'posts_per_page' => 9, 'cat' => get_query_var('cat'), 'orderby' => 'meta_value_num', 'meta_key' => hot, ..how can i set hot as a metakey 'order' => 'DESC', ); $query = array ( 'posts_per_page' => 9, 'cat' => get_query_var('cat'), 'orderby' => 'hot', ..is it possible to create an order of hot 'order' => 'DESC', );or (not sure if you can have a mathematical function in meta_key)
$query = array ( 'posts_per_page' => 10, 'cat' => get_query_var('cat'), 'orderby' => 'meta_value_num', 'meta_key' => log10(BM_META_VOTES)+(ts/45000), 'order' => 'DESC', }Finally, how do I define ts in wordpress. Thanks for your help.
The topic ‘Help with wordpress code for reddit's 'what's hot'’ is closed to new replies.