• Resolved jwt072

    (@jwt072)


    I understand I can customise a lot with the shortcodes, but how can I just include the total number of reviews in copy only on the page? For example ‘We’re thrilled that over <review number total> have trusted us to delivery their training’

    So I don’t want to display the rating summary, I just want to insert the number of reviews by category that is dynamic.

    Many thanks.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Paul

    (@pryley)

    Two ways to do this:

    1) Use an existing shortcode:

    [site_reviews_summary assigned_terms="your-category-slug" text="We're thrilled that over {num} have trusted us to deliver their training"]

    2) Create your own shortcode with a PHP snippet:

    /**
    * Use the Code Snippets (https://www.ads-software.com/plugins/code-snippets/)
    * plugin to add this shortcode to your website.
    *
    * Example usage:
    * [total_reviews assigned_posts="post_id"]
    */
    add_shortcode('total_reviews', function ($content = '') {
    $args = wp_parse_args($content, ['text' => '{num}']);
    $results = apply_filters('glsr_get_ratings', [], $args);
    $numReviews = $results['reviews'] ?? null;
    if (is_null($numReviews)) {
    return '';
    }
    return str_replace('{num}', $numReviews, $args['text']);
    });

    And use it like this:

    [total_reviews assigned_terms="your-category-slug" text="We're thrilled that over {num} have trusted us to deliver their training"]

    Or like this:

    We're thrilled that over [total_reviews assigned_terms="your-category-slug"] have trusted us to deliver their training!
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.