Support » Plugin: kk Star Ratings » The introduction of rating in Rank Math SEO

  • There is a function for function.php, with which you can integrate rankings into the Rank Match SEO plugin. How to implement kk Star Ratings ratings in this feature?

    <?php
    add_filter( "rank_math/snippet/rich_snippet_recipe_entity", function( $entity ) {
    	$entity['aggregateRating'] = [
    		"@type" => "AggregateRating",
    		"ratingValue" => "'.$star.'",
    		"reviewCount" => "value",
    	];
    	return $entity;
    });
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mrvigner

    (@mrvigner)

    I found where the necessary data is stored in the database and pulled them up. Maybe someone will come in handy:

    <?
    add_filter( "rank_math/snippet/rich_snippet_recipe_entity", function( $entity ) {
    	
    	$id = get_the_ID();
    	
    	$i = get_post_meta($id, '_kksr_casts', true ); 
    	$sumstar = get_post_meta($id, '_kksr_ratings', true ); 
    	$star = round($sumstar / $i);
    		
    		$entity['aggregateRating'] = [
    		"@type" => "AggregateRating",
    		"ratingValue" => "$star",
    		"reviewCount" => "$i",
    	];
    	return $entity;
    	
    });
    ?>

    thank you mrvinger
    that was what Im looking for
    For others – don’t forget to change the “recipe” part in ..rich_snippet_recipe_entity.. for your schema type.

    Hi guys!

    Where should I place this code? My theme’s functions.php? I apologize in advance for the newbie question!

    Does this mean that it will include aggregaterating from KK Star Ratings into Rank Math’s recipe rich snippet?

    @mrvigner @tevez87roni

    Thanks!

    Thread Starter mrvigner

    (@mrvigner)

    @matantunes

    My theme’s functions.php?

    Yes.

    Does this mean that it will include aggregaterating from KK Star Ratings into Rank Math’s recipe rich snippet?

    Yes.

    @mrvigner Amazing!

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘The introduction of rating in Rank Math SEO’ is closed to new replies.