Notifications
Clear all

Script [Solved] Answers sorting in Q&A layout

3 Posts
2 Users
0 Reactions
1,133 Views
selsebil
Posts: 88
Topic starter
(@selsebil)
Estimable Member
Joined: 3 years ago

I am using Q&A layout in my site. This layout ranks the answers according to votes. Namely, if the first answer takes less vote it ranks below. If an answer gets more vots it rises up. But I want them to be ranked from early answer to late answer from top to bottom, like other layouts. Is it possible?

2 Replies
Robert
Posts: 10520
Admin
(@robert)
Support Team
Joined: 8 years ago

@selsebil,

You can put this hook code in the functions.php file of your current active WordPress theme or use Code Snippets plugin to insert this code. Delete all caches, then delete wpForo cache in Dashboard > Forums > Dashboard admin page.

add_filter('wpforo_post_list_args', function ($args){
if(!empty($args) && !isset($_GET['orderby'])){
$args['orderby'] = '`is_first_post` DESC, `created` ASC, `postid` ASC';
}
return $args;
});
selsebil
Posts: 88
Topic starter
(@selsebil)
Estimable Member
Joined: 3 years ago

Thank you very much. It worked.