Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeff K

    (@kreitje)

    Hi viperjmu,

    Here is some example code for your themes functions.php file. You have to provide your own images and update their path in the code below though.

    function hms_rating_override($text) {
    		/**
    		 * Detect the current rating
    		 */
    		$matches = null;
    		$getMatches = preg_match('/data-rating=\"(\d)\"/', $text, $matches);
    
    		if ( count($matches) == 2 ) {
    			$rating = $matches[1];
    
    			return '<img src="/path/to/my/star/images/' . $rating . '.png" alt="' . $rating . ' out of 5 stars" itemprop="ratingValue" />';
    		}
    
    		return $text;
    	}
    	add_filter('hms_testimonials_system_rating', 'hms_rating_override');

    Hello Jeff,
    I have this on my functions.php file:

    function hms_rating_override($text) {
    		/**
    		 * Detect the current rating
    		 */
    		$matches = null;
    		$getMatches = preg_match('/data-rating=\"(\d)\"/', $text, $matches);
    
    		if ( count($matches) == 2 ) {
    			$rating = $matches[1];
    
    			return '<img src="/Users/user/Documents/Webpages/Wordpress/gomezcleaningservices.com/wp-content/themes/GCS_theme/images/ratings/' . $rating . '.png>" alt="' . $rating . ' out of 5 stars" itemprop="ratingValue" />';
    		}
    
    		return $text;
    	}
    	add_filter('hms_testimonials_system_rating', 'hms_rating_override');

    And I am positive that the images are where they are supposed to be. For example, this address displays for me a 5 star icon: file:///Users/user/Documents/Webpages/Wordpress/gomezcleaningservices.com/wp-content/themes/GCS_theme/images/ratings/5.png

    But at the moment, when I go into my testimonials page, I get a broken image. Do you have any suggestions?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rating with Stars not with numbers’ is closed to new replies.