Notifications
Clear all

Script [Solved] Sort topics by its created time, not the last reply's created time

6 Posts
2 Users
0 Reactions
1,181 Views
Posts: 49
 Joel
Topic starter
(@joel)
Trusted Member
Joined: 8 years ago

Is it possible to sort the Extended layout like you can with the Threaded layout like in the post below?  I'm not seeing the .PHP files for Extended.

 

https://wpforo.com/community/how-to-and-troubleshooting-2/sort-topics-by-its-created-time-not-the-last-replys-created-time/

5 Replies
Posts: 49
 Joel
Topic starter
(@joel)
Trusted Member
Joined: 8 years ago

FYI I found the php files for the Extended layout.

We really need posts to appear in order they were posted ....new posts at the top.

If someone does a reply we don't want that topic pushed to the top....we just want it to stay in order.

With what we are doing it is super confusing to our users as we are posting stock trade updates and every time someone does a reply it pushes it to the top.

 

1 Reply
Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10589

@joel,

You don't need any php file.

You can put this hook code in your current active WordPress theme functions.php file:

add_filter('wpforo_topic_list_args', function ($args){
if(!empty($args)){
$forumIDs = array(2, 17);
if( in_array( $args['forumid'], $forumIDs) ){
$args['orderby'] = 'type DESC, topicid ASC';
$args['order'] = '';
}
}
return $args;
});

As you can see in the 3rd line, I've added a way to only enable this ordering for certain forums, so you can insert comma separated forum ID where you want to keep topic listed by original created date. The forum IDs can be found in Forums > Forums admin page. Don't forget to update forum Ids in the code before using putting the code in functions.php file. If you need to order all topics of all forums in that way:

add_filter('wpforo_topic_list_args', function ($args){
if(!empty($args)){
$args['orderby'] = 'type DESC, topicid ASC';
$args['order'] = '';
}
return $args;
});
Posts: 49
 Joel
Topic starter
(@joel)
Trusted Member
Joined: 8 years ago

Oh this is perfect 🙂  Exactly what we needed.

Posts: 49
 Joel
Topic starter
(@joel)
Trusted Member
Joined: 8 years ago

oh Hey...one thing.. this messes up pinned posts... now they are no longer pinned.  They just sort in order now like the rest.

Any solution?

Robert
Posts: 10589
Admin
(@robert)
Support Team
Joined: 9 years ago

If you want to keep the sticky/pinned topics above all topics then use this:

add_filter('wpforo_topic_list_args', function ($args){
if(!empty($args)){
$forumIDs = array(2, 17);
if( in_array( $args['forumid'], $forumIDs) ){
$args['orderby'] = 'type DESC, topicid ASC';
$args['order'] = '';
}
}
return $args;
});