AI Assistant
Notifications
Clear all

[Solved] Answers sorting in Q&A layout

3 Posts
2 Users
0 Reactions
2,030 Views
selsebil
Posts: 88
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@selsebil)
Estimable Member
Joined: 5 years ago
[#17727]

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: 10704
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 2 months 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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@selsebil)
Estimable Member
Joined: 5 years ago

Thank you very much. It worked.


Share: