WordPress.org

Forums

WP-PostRatings
[resolved] How to change the Schema itemtype and the decimal value from the average number (6 posts)

  1. jmuller777
    Member
    Posted 1 year ago #

    Hi,

    Please, can someone help me out on this? It should be simple, but searched a lot but i just cant find how to do these 2 things, so here it goes:

    First, How to change the schema itemtype from "article" to "aggregaterating"?

    And...

    Currently the %RATINGS_AVERAGE% is outputting a value like this: "4,00" and instead i would like it to be like this "4.00" - i need to have a point instead of the comma.

    Is there any parameter i can use to do that rather than hacking the plugin code?

    Thanks in advance!

    https://wordpress.org/plugins/wp-postratings/

  2. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    1. To change schema type, you need to use the latest dev version, https://github.com/lesterchan/wp-postratings/archive/master.zip

    <?php
    add_filter('wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype');
    function wp_postratings_schema_itemtype($itemtype) {
    return 'itemscope itemtype="http://schema.org/AggregateRating"';
    }
    ?>

    2. There is no way around it without hacking the code. The code is using number_format_i18n() which takes the thousand separator from your language file.

  3. jmuller777
    Member
    Posted 1 year ago #

    Thanks a lot, the issue was fully solved!

  4. jmuller777
    Member
    Posted 7 months ago #

    I just figured out that this function is not working on pages. It works on custom pages and posts, but not on the standard wordpress pages.

    I have the code below on my function.php:

    <?php
    add_filter('wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype');
    function wp_postratings_schema_itemtype($itemtype) {
    return 'itemscope itemtype="http://schema.org/AggregateRating"';
    }
    ?>

    But on pages the output is not appearing with the the AggregateRating markup, it is displaying like this:
    <div id="post-ratings-479" class="post-ratings">... ...stuff ... ...</div>

    Could you please help me out on how to get the right markup on pages as well?

    Thanks!

  5. Lester Chan
    Member
    Plugin Author

    Posted 7 months ago #

    Redownload the https://github.com/lesterchan/wp-postratings/archive/master.zip again and replace the files. It is a big, I have fix it.

  6. jmuller777
    Member
    Posted 7 months ago #

    Works great now, that last version solved it perfectly!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic