By Luigi Di Giuseppe on Tuesday, 14 August 2018
Posted in Technical Issues
Replies 5
Likes 0
Views 637
Votes 0
Hello.
I have latest version of easy blog i have a problem with structured data setting for article's rating. Event if article is not rated yet, the vote is set to 1 and on google the rating is very low (1 star!).
The proble is here i think:

"@type": "http://schema.org/AggregateRating",
"ratingValue": "1",
"worstRating": "1",
"bestRating": "5",
"ratingCount": "1"

This is a snippet of article without any type of rating....The ratingCount should be 0 and ratingValue 0 too.

It's possibile to fix it?

Thanks
Hi there,

Currently, that how it should be as Google enforce us to use positive integer for overall rating as you can see here http://take.ms/fIsUQ.

Maybe you can try to change them here .../components/com_easyblog/themes/wireframe/blogs/entry/default.posts.php and change them accordingly using codes below and try to check them here https://search.google.com/structured-data/testing-tool

[gist type="php"]
<?php if (!$preview && $this->config->get('main_ratings') && $this->entryParams->get('post_ratings', true)) { ?>
"aggregateRating": {
"@type": "http://schema.org/AggregateRating",
"ratingValue": "<?php echo $ratings->total ? round($ratings->ratings / 2, 2) : 0; ?>",
"worstRating": "0",
"bestRating": "5",
"ratingCount": "<?php echo $ratings->total ? $ratings->total : 0; ?>"
}
<?php } ?>
[/gist]

You will shown error like screenshot given. Please advice.
·
Tuesday, 14 August 2018 10:47
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,
i know about the problem of google and i fixed in this way: if the article has a rating value i show structured data snippet with correct value of rating, nothing otherwise.

There is the snippet of code i'm currently using and all is ok my side. May you include this fix in next version if you want.


<script type="application/ld+json">
{
"@context": "http://schema.org",
"mainEntityOfPage": "<?php echo $post->getPermalink(true, true); ?>",
"@type": "BlogPosting",
"headline": "<?php echo $post->getTitle();?>",
"image": "<?php echo $post->getImage($this->config->get('cover_size_entry', 'large'), true, true);?>",
"editor": "<?php echo $post->getAuthor()->getName();?>",
"genre": "<?php echo $post->getPrimaryCategory()->title;?>",
"wordcount": "<?php echo $post->getTotalWords();?>",
"publisher": {
"@type": "Organization",
"name": "<?php echo EB::showSiteName(); ?>",
"logo": <?php echo $post->getSchemaLogo(); ?>
},
"datePublished": "<?php echo $post->getPublishDate(true)->format('Y-m-d');?>",
"dateCreated": "<?php echo $post->getCreationDate(true)->format('Y-m-d');?>",
"dateModified": "<?php echo $post->getModifiedDate()->format('Y-m-d');?>",
"description": "<?php echo EB::jconfig()->get('MetaDesc'); ?>",
"articleBody": "<?php echo htmlentities($content, ENT_QUOTES);?>",
"author": {
"@type": "Person",
"name": "<?php echo $post->getAuthor()->getName();?>",
"image": "<?php echo $post->creator->getAvatar();?>"
}
<?php if (!empty($ratings->total)) {?>
<?php if ( !$preview && $this->config->get('main_ratings') && $this->entryParams->get('post_ratings', true)) { ?>
,
"aggregateRating": {
"@type": "http://schema.org/AggregateRating",
"ratingValue": "<?php echo $ratings->total ? round($ratings->ratings / 2, 2) : 1; ?>",
"worstRating": "1",
"bestRating": "5",
"ratingCount": "<?php echo $ratings->total ? $ratings->total : 1; ?>"
}
<?php } ?>
<?php } ?>
}

</script>
·
Wednesday, 15 August 2018 17:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there,

Thanks for the insight.
·
Wednesday, 15 August 2018 17:48
·
0 Likes
·
0 Votes
·
0 Comments
·
hi stackteam, would be cool when this modifications could be included in Easyblog.
·
Wednesday, 15 August 2018 21:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Michael,

We have logged this on our issues trackers.
·
Thursday, 16 August 2018 09:56
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post