Arrange BBpress topics by created

The default setting in the bbpress forum topics is that the most active topic automatically gets on top (sorted by freshness). However, I wish to change this setting in descending order of topics created or by topic id. I have tried to locate the template file to make these changes but could not get. Any help is appreciated.

Solutions Collecting From Web of "Arrange BBpress topics by created"

Add this to a plugin or your active themes functions.php

function my_custom_display_topic_index_query () {
  $args['orderby'] = 'date';
  $args['order']   = 'DESC';

  return $args;
}
add_filter('bbp_before_has_topics_parse_args', 'my_custom_display_topic_index_query' );

You should also include the $args argument. Here is an example where the sort order of topics is changed for just one forum:

//* Change sort order of Topics within a specified bbpress forum
function my_custom_display_topic_index_query ($args) {
  $thisforumid = bbp_get_forum_id();

  if($thisforumid == 43135) {
    $args['orderby'] = 'date';
    $args['order']   = 'ASC';
  }

  return $args;
}
add_filter('bbp_before_has_topics_parse_args', 'my_custom_display_topic_index_query '     );