Sort forums by number of topics in each forum
I’m trying to sort the display of the forums depending on the number of topics within the forum. Could somebody help me with a query for this? I’ve tried using a custom query but just cant seem to get it right.
I know there’s a PHP function bbp_forum_topic_count() but I need this all within one loop, not PHP.
Any help would be much appreciated.
This was how far I got with my custom query:
SELECT SQL_CALC_FOUND_ROWS wp_posts.*, topics.total FROM wp_posts, (SELECT COUNT(wp_posts.ID) as total FROM wp_posts) topics WHERE 1=1 AND wp_posts.post_type = ‘forum’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘hidden’ OR wp_posts.post_status = ‘private’)
- You must be logged in to reply to this topic.