This correctly sort posts by thumbs vote (GD star rating plugin):
<?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2&post_parent='.$post->ID); ?>
<?php while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
But this doesn’t sort them at all:
<?php $custom_posts = new WP_Query(); ?>
<?php $custom_posts->query('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2&post_parent='.$post->ID); ?>
<?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
<div class="content-block-2">
<?php bbp_reply_author_link( array( 'type' => 'avatar' ) ); ?>
<?php bbp_reply_author_link( array( 'type' => 'name' ) ); ?>
<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; ?>
It seems GD Star Rating uses
get_query_var()
to read query variables, which only reads this global$wp_query
variable.query_posts()
overwrites the global$wp_query
variable, so it works there, but creating a newWP_Query
(which is a good practice) will not work. You should contact the plugin author and ask for a fix.Cilvic’s advice works for me. Just set the GET parameters before using WP_Query.