This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Dynamically filtering bbpress topics and replies based on currently viewed Forum

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Dynamically filtering bbpress topics and replies based on currently viewed Forum Reply To: Dynamically filtering bbpress topics and replies based on currently viewed Forum

#34675
nickchomey18nickchomey18
Participant

As it turns out, I was able to get this to work by using the $options[‘current_page_id’] field and the following snippet. You’re welcome to share it with the community – it seems to me that it is very useful for anyone using ASP with bbpress. Do you see anything about it that could be changed/improved?

add_filter('asp_query_args', 'asp_filter_forum', 10, 3);
function asp_filter_forum ( $args, $search_id, $options) {
  if ($search_id == 4) {
    $forum_id = (int)$options['current_page_id'];
    $args['post_meta_filter'][] = array(
      'key' => '_bbp_forum_id',
      'value' => array ($forum_id),
      'operator' => '=',
      'allow_missing' => false
    );
  }
  return $args;    
}

Anyway, I am still curious as to whether it is possible to pass a custom variable/parameter/argument to an ASP shortcode? Would it involve editing the ASP source code to add another parameter to the filter, or is there another way?