Notifications
Clear all

Script [Solved] Answers sorting in Q&A layout

3 Posts
2 Users
0 Reactions
1,307 Views
selsebil
Posts: 88
Topic starter
(@selsebil)
Estimable Member
Joined: 4 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: 10590
Admin
(@robert)
Support Team
Joined: 9 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: 4 years ago

Thank you very much. It worked.