WordPress : Issue with wp_query and gd star rating plugin

I have used GD Star Rating plugin with my WordPress installation, for creating 2 different sets of Ratings (Posts and Videos). (I was not able to find any other plugin that supports this feature).

I have used following arguments in one wp_query to display a list of top rated videos, and it’s working fine.

Read More
$args=array(
    'post_type' => 'youtube_videos',
    'post_status' => 'publish',
    'posts_per_page' => 10,
    'gdsr_sort' => 'rating',
    'gdsr_multi' => 3
);

On the same page, i am trying to show a list of top rated posts, with following arguments in wp_query, but it’s not working.

$args=array(
    'posts_per_page' => 4,
    'post_type' => 'post',
    'gdsr_sort' => 'rating',
    'gdsr_multi' => 0
);

I found that issue is with value passes in ‘gdsr_multi’ varibale, if i remove this variable from the top rated videos 2nd part of code works fine.

I am not being able to run both together, any suggestions please?


For gdsr_multi variable documentation of GD Star rating plugin says:

  • For standard rating data, don’t use this variable, or set it to zero.
  • To get multi ratings data this variable must be set to multi set id to use.

Related posts

Leave a Reply

1 comment

  1. You should reset your query before start a new one. wp_reset_query(); will destroys the previous query used on a custom Loop. This function should be called after The Loop to ensure conditional tags work as expected. As example:

    <?php
        query_posts( 'post_parent=5' );
        if ( have_posts() ) :
           while ( have_posts() ) : the_post();
           ?><a href="<?php the_permalink() ?>"><?php the_title() ?></a><br /><?php
           endwhile;
        endif;
        wp_reset_query();
       //your second query will be here.
    ?>
    

    For more details, you can check WordPress official codex: wp reset query