• peter.bohus

    (@peterbohus)


    Hi,
    I am building template for blog about food and mainly I would like to use it for rating on recipe.
    If I switch rich snippets there is issue.
    whole my content have set itemprop to http://schema.org/Recipe
    …but kk star rating add its own itemprop to Blog

    How can I change it (I can hard-code it – but i am afraid, that after update I will lose it).
    …is it possible to change it to:
    itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"
    …which is more common?

    Not everybody will use it only for blog rating.

    Thanks Peter

    I use google rich snippets testing and rating stand out of recipe – it is shown as blog – for correct using of rating within rich snippets it should not be set to blog.

    https://wordpress.org/plugins/kk-star-ratings/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter peter.bohus

    (@peterbohus)

    …so if somebody else see it as problem and understand little bit of php, then:

    in file ../plugins/kk-star-ratings/index.php on lines 654 – 673:

    if($score)
    {
     $votes = get_post_meta($id, '_kksr_casts', true) ? get_post_meta($id, '_kksr_casts', true) : 0;
     $avg = $score ? round((float)(($score/$votes)*($best/5)), 2) : 0;
     $per = $score ? round((float)((($score/$votes)/5)*100), 2) : 0;
    
     $leg = str_replace('[total]', '<span itemprop="ratingCount">'.$votes.'</span>', $legend);
     $leg = str_replace('[avg]', '<span itemprop="ratingValue">'.$avg.'</span>', $leg);
     $leg = str_replace('[per]',  $per .'%', $leg);
     $leg = str_replace('[s]', $votes == 1 ? '' : 's', $leg);
    
     $snippet = '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
     $snippet .= '    <div itemprop="name" class="kksr-title">' . $title . '</div>';
     $snippet .= '    <div>';
     $snippet .=              $leg;
     $snippet .= '            <meta itemprop="bestRating" content="'. $best . '"/>';
     $snippet .= '            <meta itemprop="worstRating" content="1"/>';
     $snippet .= '    </div>';
     $snippet .= '</div>';
    }

    …do not forget to make backup before changing and also after changing… (after changing is good for – after update – just make mark, where you did changes – to easy change back).

    …it is not ideal, but it is clear for Rich snippets. …to be sure, check changes HERE

    …this mark-up is not only for Recipes, it should work on each page, where are Rich snippets used correctly – mean this should be inherited…

    Plugin Contributor Kamal Khan

    (@bhittani)

    Can you send a pull request at https://github.com/kamalkhan/kk-star-ratings so I may update the plugin.

    Thanks.

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