title: How can I override BBPress function bbp_has_topics() by adding a filter for this function in Wordpress?
body: <p>The "<strong>bbp_has_topics</strong>" function in "<strong>public/wp-content/plugins/bbpress/includes/topics/template.php</strong>" fetches the topics by "<strong>meta_value</strong>" in a "<strong>Descending</strong>" order. I need to override this behaviour to fetch the post by "<strong>created date</strong>" <strong>without editing this file</strong>. So is there a way to add a filter for this "bbp_has_topics". I added a filter in <strong>functions.php</strong> as below. But in the listing page the pagination links are not showing.</p>
  
  <p>function mybbp_has_topics( $args = '') {
      $bbp = bbpress();</p>
  
  <pre><code>// Other defaults
  $default_topic_search  = !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
  $default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) &amp;&amp; ( false === $default_topic_search );
  $default_post_parent   = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
  
  // The default forum query for most circumstances
  $default = array(
      'post_type'      =&gt; bbp_get_topic_post_type(), // Narrow query down to bbPress topics
      'post_parent'    =&gt; $default_post_parent,      // Forum ID
      'meta_key'       =&gt; '_bbp_last_active_time',   // Make sure topic has some last activity time
      'orderby'        =&gt; 'date',              // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand',
      'order'          =&gt; 'DESC',                    // 'ASC', 'DESC'
      'posts_per_page' =&gt; bbp_get_topics_per_page(), // Topics per page
      'paged'          =&gt; bbp_get_paged(),           // Page Number
      's'              =&gt; $default_topic_search,     // Topic Search
      'show_stickies'  =&gt; $default_show_stickies,    // Ignore sticky topics?
      'max_num_pages'  =&gt; false,                     // Maximum number of pages to show
  );
  
  $r = bbp_parse_args( $args, $default, 'has_topics' );
  
  // Run the query
  $bbp-&gt;topic_query = new WP_Query( $r );
  
  return apply_filters( 'mybbp_has_topics', $bbp-&gt;topic_query-&gt;have_posts(), $bbp-&gt;topic_query );
  </code></pre>
  
  <p>}</p>