• Resolved Zurd

    (@zurd)


    Random testimonials is not a feature in WP Customer reviews 2.4.5, I thought it would be fun to add this feature and it was. Hopefully, the creator of this plugin could add my code in the next release.

    Here’s how to add the feature and it’s not difficult.

    First, in the shortcode, call it with the variable RANDOM=”1″ like so :
    [WPCR_SHOW POSTID="ALL" NUM="1" SNIPPET="170" MORE="" HIDECUSTOM="0" HIDERESPONSE="0" RANDOM="1"]

    Open up wp-customer-reviews.php and add these codes at the line I’m saying, please note that it might not be the exact same lines because I modified the file before, it’s really close though.

    Line 392 :
    function get_reviews($postID, $startpage, $perpage, $status, $random) {

    Line 620 :
    function output_reviews_show($inside_div, $postid, $perpage, $max, $hide_custom = 0, $hide_response = 0, $snippet_length = 0, $show_morelink = '', $random = 0) {

    Line 627 :
    $arr_Reviews = $this->get_reviews($postid, $thispage, $perpage, 1, $random);

    Line 1297 :
    extract( shortcode_atts( array('postid' => 'all','num' => '3','hidecustom' => '0','hideresponse' => '0', 'snippet' => '0','more' => '', 'random' => '0'), $atts ) );

    Line 1306 :
    $random = intval($random);

    Line 1315 :
    $ret_Arr = $this->output_reviews_show( $inside_div, $postid, $num, $num, $hidecustom, $hideresponse, $snippet, $more, $random );

    And finally, where the magic happens, at around line 413, you should see an SQL query like so : FROM $this->dbtable WHERE $qry_status $and_post ORDER BY date_time DESC $limit, copy it one more time and modify the whole thing like so :

    if ( $random ) {
            $reviews = $wpdb->get_results("SELECT
                id,
                date_time,
                reviewer_name,
                reviewer_email,
                review_title,
                review_text,
                review_response,
                review_rating,
                reviewer_url,
                reviewer_ip,
                status,
                page_id,
                custom_fields
                FROM $this->dbtable WHERE $qry_status $and_post ORDER BY RAND() DESC $limit
                ");
    }
    else {
          	$reviews = $wpdb->get_results("SELECT
                id,
                date_time,
                reviewer_name,
                reviewer_email,
                review_title,
                review_text,
                review_response,
                review_rating,
                reviewer_url,
                reviewer_ip,
                status,
                page_id,
                custom_fields
                FROM $this->dbtable WHERE $qry_status $and_post ORDER BY date_time DESC $limit
                ");
    }

    Note that I removed the backticks in this code because they are used in this forum as a code tag. Just look at the original code and put them where they are supposed to go.

    https://www.ads-software.com/extend/plugins/wp-customer-reviews/

Viewing 3 replies - 16 through 18 (of 18 total)
  • hig116

    (@hig116)

    Thanks for continuing to try and help. I’m still getting this error in the admin area.

    Warning: Missing argument 5 for WPCustomerReviews::get_reviews(), called in /home/content/45/10376245/html/wp-content/plugins/wp-customer-reviews/wp-customer-reviews-admin.php on line 957 and defined in /home/content/45/10376245/html/wp-content/plugins/wp-customer-reviews/wp-customer-reviews.php on line 385

    Keith

    Thread Starter Zurd

    (@zurd)

    Paste me your line 385 from wp-customer-reviews.php

    benpines

    (@benpines)

    global $wpdb;

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘How to have random testimonials’ is closed to new replies.