Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using bbPress. I'm in a single page of the custom post type bbp_topic. As you can imagine this custom post type stores another custom post type called bbp_reply. I'm using the following query to list the most voted replies at the top (like Youtube), helped by the GD start rating plugin:

        <?php $custom_posts = new WP_Query(); ?>
        <?php $custom_posts->query('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2'); ?>
        <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
            <div class="content-block-2">
                <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
            <?php the_content(); ?>
            </div>
        <?php endwhile; ?>

The problem is that the query is listing all the replies from all the bbp_topic custom post type. I need to query something like this: list all the custom post types bbp_reply from this single bbp_topic custom post type you are viewing right now.

(I know how to get the ID of the current bbp_topic custom post type: $post->ID but I'm not very sure how to use it).

Any suggestions?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It appears the topic of a reply is stored in the _bbp_topic_id meta field. Older versions stored this in the post_parent field, but it seems this is deprecated? So you can add '&meta_key=_bbf_topic_id&meta_value=' . $post-ID to your query to get only replies to this topic.

share|improve this answer
    
@Jan Fabry Yes, post_parent=' . $post-ID did it. –  janoChen Mar 24 '11 at 9:22
add comment

Your Answer

 
discard

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.