Skip to main content
Technology

How bbPress search should work?

There was an interesting discussion during the last bbPress dev meeting about the different approaches for implementing a solid search feature for the forums, and how it should play along with the general WordPress search. Here’s the main ticket. I’d like to keep the dialog going and will summarize the core ideas.I’m writing this without reviewing the whole chat and didn’t take notes, so… sorry in advance if I’m missing someone’s opinion or idea. Please do let me know in the comments.

bbPress side of things

Let’s concentrate first on how the bbPress search should work. Specifically, what should you get when you search for a keyword. There seems to be three main approaches:

Search all, return all

When you search for a keyword, bbPress looks for its custom post types (Forums, Topics and Replies) and will return all items that match the keyword. It should show in the search results template what kind of element each link corresponds to. Maybe it’d make sense to show results for Forums at the top, and Topics+Replies next. For this kind of search, returning items ordered by recency seems to be the logic way to go.

Search replies, return replies

Pretty much the same as the last approach, but the results will only contain links to replies. I think someone mentioned phpBB does this, but I’m not sure. This approach seems best suited for a forum where recency has a lot of weight (news, tech, etc).

Search replies, return topics

In this case bbPress will look for the keyword in replies, but return only the parent topics of those matched replies. Of course it’d show each topic only once. Interestingly, here, the results could be ordered by relevance instead of recency (the count of replies in that topic that match the searched keyword). I’m totally biased, because almost all my experience with bbPress is implementing big scale support forums, and for support this approach wins every time.

Regardless of the approach, we should also consider the idea of having an advanced search mode out-of-the-box, where you could, at least, filter on which Forum you want to search. Maybe make it context aware? If I’m in a Forum, it searches within this forum. If I’m at a Topic it searches within it’s replies.

Let’s not forget pages & posts!

The second part of the discussion is harder to solve. How bbPress search should integrate with the standard WordPress search? Here we agreed this seems more like an UX problem than a technical one. Again, a couple of different approaches:

Independent

By far, the easiest to implement. Let’s just have a different search box for bbPress, use a different query_var, keep the bbPress custom post types defined as exclude_from_search and off we go. (Actually, jjj showed us that this is kinda already implemented, at least for topics: example)

Independent but unified

Use the same WordPress search form, but when the users initiate a search from a non bbPress page, run the normal search. If the user searches from inside a bbPress page, run our search. I’ve implemented this in the past and I don’t like it. It’s quite confusing to get different behaviors for the same action.

Integrated

Again, totally biased, but I love how we resolved this here at Modern Tribe (example). I think for some sites it’d be a killer feature the ability to combine results like that. To be honest, I can’t think of a bbPress implementation I’ve done that would not be well served with a search results page like this one. On the other hand, the general consensus was that making something like this look good in any theme would by quite impossible. Specially when you realize we need to take into account custom post types, different ratios of content in each content type, etc.

I’m probably forgetting parts of the discussion, and this is getting long, so I’ll shut up now and make room(?) for you in the comments. What do you think?

Contributors

Peter

Peter

I lead a fantastic team of WordPress developers building enterprise level WordPress systems. On occasion I have been known to speak at conferences on the topics of Freelancing, WordPress, and the meaning of life, though I tend to spend much of my performance energy on my music. Perhaps one day I will figure out how to merge the two without having to write songs about debugging Javascript.