Sort by highest rated
-
It would be nice if you could make a shortcode that would sort topics or replies by most votes, highest rated, etc. Like other voting plugins. Or at least a widget. Thanks!
-
Done! I just released version 1.1.5 where I added a filter, sort_bbpress_replies_by_votes, to enable a new feature that sorts replies by voting score.
Add this filter hook into your child theme’s functions.php file…
add_filter('sort_bbpress_replies_by_votes', '__return_true');Great, Thank you
Clive
Hi,
Just found out that if I set the filter to sort by votes there is a problem, if a topic has no replies, the topic content does not show up.
Thank you for bringing this to my attention. I found the bug and fixed it in version 1.1.6. Please update and let me know if you find any other issues. Thanks!
Hi,
Could you check the fix please, I have some topics that had no replies and zero votes and they are not showing up but the ones with votes and replies are.Thanks
Sorry about that. I fixed part of the issue, but not that case. I fixed it now. Please update and try again. Thanks.
Great they are showing up now.
The topic always shows up first, however many votes it has, is it possible to include the topic into the sort with the replies, not sure if what I am saying is clear so if you look at https://wateratairports.com/topic/london-gatwick-lgw/ you should see what I mean. I do understand that others may want it the way you have done it.
Thanks
I don’t think that would be a good idea. The replies are sorted by votes, but the topic (or original post) should always remain at the top because that is the question that the replies are answering, or that is the instructions that the replies are following.
Hi,
Thanks, I know that the way it works is the case for most people, my site is a bit different to others in that there is only one question asked for the whole site and each topic becomes the answer for different locations. I will look at trying to adjust my site. I really do appreciate your work.Regards
Clive
You can put this code in your theme’s functions.php file and it should do the trick…
// Override to sort topics and replies by votes add_filter('bbp_has_replies_query', 'sort_bbpress_topics_and_replies_by_votes', 11); function sort_bbpress_topics_and_replies_by_votes( $args = array() ) { if(!apply_filters('sort_bbpress_replies_by_votes', false)) return $args; $bbPress_post_id = get_the_ID(); $bbPress_post_type = get_post_type($bbPress_post_id); if( $bbPress_post_type == bbp_get_topic_post_type() ){ $args['orderby'] = [ 'meta_value_num' => 'DESC' ]; } return $args; }Great, thanks a lot
The topic ‘Sort by highest rated’ is closed to new replies.