• Resolved broder

    (@broder)


    Not sure if I’m in the right place for this, but I’m trying to display the review count next to the stars in the Woocommerce loop title (which works). However I would like it to display only when there are 1 or more reviews.

    <div class="<?= $style; ?> glsrw-loop-rating" style="display: inline-block; margin: 0 auto;">
    <?php if ($ratings->reviews ==1) : ?>
    <?= glsr_star_rating($ratings->average); ?><div class="count">(<?= sprintf('%s TEST', $ratings->reviews, 'woocommerce'), '<span class="count">'.esc_html($ratings->reviews).'</span>');?>)</div>
    </div>
    

    And via hook

    add_action('site-reviews-woocommerce/render/loop/rating', 'review_count_cat');
    
    function review_count_cat() {
    if($ratings->reviews ==4) {
    ?>
    <div class="hey">hi
    	</div>
    <?php
    } else {
    	?>
    	<div class="hi">hey
    	</div>
    <?php
    }
    }

    One gives error, other ignores condition.

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

    (@geminilabs)

    1. Copy:

    /wp-content/plugins/site-reviews-woocommerce/templates/loop/rating.php

    Into your child theme like this:

    /wp-content/themes/your-child-theme/site-reviews-woocommerce/loop/rating.php

    2. Edit the file that you copied like this:

    <?php defined('WPINC') || die;
    
    if (empty($ratings->average)) return;
    
    ?>
    
    <div class="<?= $style; ?> glsrw-loop-rating" style="display: inline-block; margin: 0 auto;">
        <?= glsr_star_rating($ratings->average); ?>
    </div>

    In future, please use the Support form on your Nifty Plugins account for help with the add-ons.

    • This reply was modified 2 years, 9 months ago by Gemini Labs.
    Thread Starter broder

    (@broder)

    (empty($ratings->average)) is what I was looking for, thank you. Will do next time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Review count site reviews woocommerce loop title’ is closed to new replies.