With the introduction of the new BB_Query_Class in bbPress 0.8.3, the old method of adding custom “views” to bbPress has been removed. You should no longer directly manipulate the $bb_views array, nor does the bb_views hook work.
To add a view, you should instead use a new function: bb_register_view(). Also available is bb_deregister_view() for removing the default views or views added by other plugins.
function my_plugin_views() {
/*
bb_register_view(
$view_slug,
$view_title,
$bb_query_argument_array
);
*/
bb_register_view(
'more-than-5',
'Topics with more than five posts',
array( 'post_count' => '>5' )
);
bb_register_view(
'old-timers',
'Topics started before 2005',
array( 'started' => '<2005' )
);
// Remove default 'Topics with no tags' view
bb_deregister_view( 'untagged' );
}
add_action( 'bb_init', 'my_plugin_views' );
If you really need more complicated queries, you have the following filters at your disposal, just by registering your view in the above fashion (assuming the $view_slug is “my-view”).
bb_view_my-view_distinctbb_view_my-view_fieldsbb_view_my-view_joinbb_view_my-view_wherebb_view_my-view_group_bybb_view_my-view_havingbb_view_my-view_order_bybb_view_my-view_limit
If that sounds complicated, it probably is
Most plugin developers will never have to do much besides filter a join or where here and there.
Search
About This Entry
- You’re currently reading “BB_Query Class and custom bbPress views,” an entry on The Staff Lounge
- Published at 9.27.07 / 1am
Related Entries
- bbPress 1.0-alpha-2 released - MetabbPress
- BuddyPress: Customizable Slugs in BuddyPress - Wordpress
- bbPress 0.9 released - bbPress
- bbPress 0.9 notes for plugin developers - bbPress
- Weblog Tools Collection: Adding Scripts Properly to WordPress Part 1 – wp_enqueue_script - Wordpress
Recent Entries
- Dev Blog: WordPress 3.0.1 - Wordpress
- vBulletin 3.8.7 coming - vBulletin AnnouncementsvBulletin.com
- Weblog Tools Collection: WordPress Plugin Releases for 07/29 - Wordpress
- Matt: New Kindle - Wordpress
- vBulletin.com is now running on vB 4.0.6 - vBulletin AnnouncementsvBulletin.com
Popular Resources
- Phorum-5.2.8 final released (12 replies) - 41316 Views
- Phorum-5.2.9a released (10 replies) - 34031 Views
- IPB Resources - 19610 Views
- Weblog Tools Collection: WordPress Plugin Releases for 02/07 - 16020 Views
- Phorum-5.2.9 released! Security Upgrade! (no replies) - 12702 Views







No Responses to “BB_Query Class and custom bbPress views”
Please Wait
Leave a Reply