Hi everyone,
I searched on how to add a dropdown list of bbpress forums and could not find any resource. Most of them were outdated, while some of them didn’t work. So I look around into the bbpress plugin core and found the solution.
I am posting the solution if anyone else will require it.
A thing to note here is the is to change the prefix_ to you plugin or theme prefix.
I have made use of the WordPress transient API as well. We need to delete the transient when save/update to forum occurs. For that, just add the following code that will delete the transient when posts are saved/updated.
This will display a list of forum which will go to the selected forum page when selected.
Now, just call function prefix_bbpress_dropdown_forum_list() or hook it anywhere you to get the results.