WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is how you do it for Wordpress posts:

   $my_query = new WP_Query( "cat=3" );
   if ( $my_query->have_posts() ) { 
       while ( $my_query->have_posts() ) { 

I would like to know how to do that in bbPress (say, listing topics).

share|improve this question
up vote 1 down vote accepted

bbpress has its own query class called BB_Query()

and it accepts:

    $ints = array(
            'page',     // Defaults to global or number in URI
            'per_page', // Defaults to page_topics
            'tag_id',   // one tag ID
            'favorites' // one user ID

    $parse_ints = array(
        // Both

        // Topics

        // Posts

    $dates = array(
        'started',  // topic
        'updated',  // topic
        'posted'    // post

    $others = array(
        // Both
        'topic',    // one topic name
        'forum',    // one forum name
        'tag',      // one tag name

        // Topics
        'topic_author', // one username
        'topic_status', // *normal, deleted, all, parse_int ( and - )
        'open',         // *all, yes = open, no = closed, parse_int ( and - )
        'sticky',       // *all, no = normal, forum, super = front, parse_int ( and - )
        'meta_key',     // one meta_key ( and - )
        'meta_value',   // range
        'topic_title',  // LIKE search.  Understands "doublequoted strings"
        'search',       // generic search: topic_title OR post_text
                        // Can ONLY be used in a topic query
                        // Returns additional search_score and (concatenated) post_text columns

        // Posts
        'post_author',  // one username
        'post_status',  // *noraml, deleted, all, parse_int ( and - )
        'post_text',    // FULLTEXT search
                        // Returns additional search_score column (and (concatenated) post_text column if topic query)
        'poster_ip',    // one IPv4 address

        // SQL
        'index_hint',   // A full index hint using valid index hint syntax, can be multiple hints an array
        'order_by',     // fieldname
        'order',        // *DESC, ASC
        'count',        // *false = none, true = COUNT(*), found_rows = FOUND_ROWS()
        '_join_type',   // not implemented: For benchmarking only.  Will disappear. join (1 query), in (2 queries)

// Utility
//          'append_meta',  // *true, false: topics only
//          'cache_users',  // *true, false
//          'cache_topics,  // *true, false: posts only
//          'post_id_only', // true, *false: this query is only returning post IDs
            'cache_posts'    // not implemented: none, first, last
share|improve this answer
So I a custom bbPress loop should I use has_posts or the_post? – janoChen Feb 28 '11 at 7:26

@janoChen - The exact same method can be used to get bbPress forums/topics/replies, as well as there being a few built in functions that act as wrapper functions for them.

If you can reply back with exactly what kind of information you're trying to get, I can show you how to build the query. (I.E. you want the 14 most recent public topics, you want the most recent 25 replies by user_id 7, etc...)

share|improve this answer
I want to list the two most recent published topics under each title of the forums (forums page). – janoChen Mar 1 '11 at 4:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.