bbPress has twenty or so functions that select groups of topics or posts from the database. Some of them do very specific things, and some of them do something only slightly different from another such function.

Maintaining this large group of functions and keeping them all consistent was beginning to become a nuisance. Additionally, it was annoying to have either to write a whole new function or to hack filters into and onto an existing function every time a new database query was needed.

To help alleviate both of these problems, the next version of bbPress will come with a BB_Query class, which all of the above referenced functions will use.

For developers and plugin authors, this means it’ll will now be really easy to query the database for posts and topics based on whatever arbitrary criteria is needed. For users, the following couple paragraphs will be boring, but see the news below 🙂

Example

As an example, the following code will select all the topics written by mdawaffe in June of 2007 and having the “bbPress” tag and will sort those topics by their start time.


$topic_query = new BB_Query( 'topic',
	array(
		'topic_author' => 'mdawaffe',
		'started' => '2007-06',
		'tag' => 'bbpress',
		'order_by' => 'topic_start_time'
	)
);
$topic_query->results; // Here's the array of topics the query returned.

Both the incoming parameters and the SQL query that the class generates are highly filterable (in a way that’s backward compatible with the current version of bbPress), so further customization should be easy. Also, the BB_Query class can automatically handle pagination, caching and more, so you can relax and get on with more interesting things.

New feature: better search

In the end, though, we write code for users, not for developers; we want the user experience to be as pleasant as possible. With all these new bells and whistles, users get some pretty cool new features.

The default theme will now let you constrain your search to an individual forum (and adding that ability into other themes will be super easy). Adding extra constraints (like searching by tag or author) will be easy too.

In the admin section, you can search both topics and posts by a number of criteria.

bbPress Topic Search

bbPress Post Search

Next stop… Pingbacks. (sshhh! It’s a secret!)