• Resolved jackking12

    (@jackking12)


    Hi. Back after a while with a question. I have been stumped by a simple thing and not sure how to proceed with it. I am trying to create a slider using a custom wp query:

    $reviews = glsr_get_reviews([
    ‘assigned_posts’ => ‘post_id’,
    ‘status’ => ‘approved’, // value can be “all”, “approved”, or “unapproved”
    ]);

    This is sort of a basic way i have been pulling the reviews whilst i play around with it. I have 2 questions with it, firstly i understand ‘display’ will allow me to specify the amount it should fetch in one go. Any ideas how to incorporate that into a slider function so if one of the assigned pages has 500 assigned reviews, its not querying the 500 in one run?

    Secondly, how do i add a pagination query to glsr_get_reviews? Whilst experimenting with it, i cannot seem to get any response from it.

    Appreciate any direction you can give me on it, long time fan of the plugin and appreciate the work you have put into the plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    // Get page 3 of reviews, with 12 reviews per page
    $reviews = glsr_get_reviews([
        'display' => 12,
        'page => 3,
    ]);
    
    // The total number of reviews found
    $reviews->total;
    
    // The maximum number of pages that can be displayed based on the "display" parameter
    $reviews->max_num_pages;
    
    // Render and print the reviews to the page
    $rendered = $reviews->build();
    foreach ($rendered as $renderedReview) {
        echo $renderedReview;
    }
    
    // Print the generated pagination to the page
    echo $rendered->pagination;

    See also the included documentation for the glsr_get_reviews function on the Site Reviews > Help & Support > Functions page.

    Thread Starter jackking12

    (@jackking12)

    Exactly what im looking for. Perfect and much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Slider feature’ is closed to new replies.