Knowledge Base

BBPress: Filtering Topics and Replies by Forums (custom field based)

in Ajax Search Pro Tutorials Tags: bbpressfilterforumforum filtertutorial

This tutorial describes how to use the BBPress forums as a drop-down filter for topics and replies.

BBPress stores the main forum ID for each topic and reply within the _bbp_forum_id custom field – thus allowing the plugin to filter topics and replies by them. Follow the steps below to achieve a forum based drop-down filter

  1. Make sure that the Topic and/or the Reply post type is actually selected for searching – under the General Options -> Sources panel
  2. Then, first we need to get the Forum IDs. To do that go to the Forums menu, and click on the edit button. The Forum editor will open, and in the browser address bar you will see the ID. Take note of all forum IDs and names, that you need in the filter.

  3. Now, that the IDs and the names are noted, it is time to create the filter on the  _bbp_forum_id custom field. Go to the Frontend search settings -> Custom fields panel, and create a filter like so:

    The 'Dropdown values' should be edited as {forum ID}||Forum name per each line. In the example case, we had two forums with IDs 406 and 411. Our finale value for the two items was:

    ||Choose a forum**
    406||Test forum 1
    411||Test forum 2

    Feel free to use this as a sample.

  4. Also, keep in mind, that filter are not visible by default, so make sure to check the General configuration. We used this configuration:

    ..and this results in this layout: