I need some help creating a specific WordPress query and I am drawing a blank on how to do it.
I want to select n posts ordered by the sum of the inverse of the age in days of the comments. I'd like to use the WP_Query class if I can but I'm unsure how to proceed.
If I was doing raw SQL I'd do something like:
SELECT *, SUM(1/(DIF(table1.date,NOW()))) as score
FROM table1 INNER JOIN table2 ON table1.id = table2.fk_id
GROUP BY table1.id
ORDER BY score
LIMIT 10;
This is how Facebook used to calculate the edgerank for posts. I want to do this for "trending posts". Obviousely, I then want to run a loop to output the posts.
Can I do that natively?