Support » Plugin: Rate my Post - WP Rating System » Voting not working on Google AMP servers

  • First of all thanks for creating this nice plugin. We have been testing it for the last week and it works very good. There is one problem we encountered where we are not sure how to fix it (if possible)

    We use the plugin with AMP (AMP Plugin) and voting works fine on the AMP version of the website as well, but when a user comes from the google search to the AMP version cached on the Google servers, stars are shown and it allows you to vote, but after clicking on one of the stars, it returns an error message and not data is forwarded to the database. This only happens when AMP is served from Google directly (easiest way to test is with chrome on a mobile device (if served from google directly the result is a marked with an small icon in the search results)

    Thanks for your help and support!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Blaz K.


    Hi @dontwakeme,

    Any chance you could send me a link so I can test? The thing is that I don’t have any AMP website and thus it’s difficult for me to debug this. By the way, what does the error say?

    Hello @blazk,
    thanks for the fast reply.

    We currently testing in on this website:
    HTML Version:
    AMP Version:

    as mentioned both work fine but not when AMP is served from google server the error occurs. Error message: “There was an error rating this post”
    To reporduce this I would suggest using chrome on a mobile device.
    Surf on your moible to:

    If it this not work you can take the route through normal search on your mobile device:

    this query should feature the website on one of the top poistions. If AMP is served from Google directly the search result has a small icon next to it.
    After clicking on the result you should not be taken to the domain itself but to a google server so the URL will be something like:

    Thanks for your time and help!

    Plugin Author Blaz K.


    I see the problem. My guess is that the issue is caused by headers in public function process_rating_amp() on line 323 in wp-content/plugins/rate-my-post/public/class-rate-my-post-public.php. More about this here. Any chance you could test if this is the problem?


    I am no dev, but I will try to test if this is the cause of the problem (seems very likely after reading into it)
    I have checked out the resource on the amp website as well:

    so what i did now is adding the amp project URL of the website to the file:


    It will take some time to get it online and for google servers to update as well (if this is necessary) but if it works, it should proove where ther error comes from.

    Of course this is not a really good solution since it won’t work that easily on multipress. Well we will see I guess.

    If you have other suggestions please let me know!
    I will tell you once our test is done. Thanks for your time and help!

    Already found my first mistake:


    since – gets converted into — in the AMP URL.

    Well this did not work. Sorry!
    Do you have any code example that I should try?

    Again another update since i did not fully test it before.

    So with this solution the error message is still shown after voting on AMP, BUT the vote gets counted and the voting count goes up in the database. So it seems like vote gets through but besides this there is still an error message. Maybe allow-origin has to be added somewhere else as well? But this is just me guessing – sry!

    Plugin Author Blaz K.


    @dontwakeme, sorry for my late reply. Have you tried setting the headers like this:

    $domain_url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]”;
    header(“Content-type: application/json”);
    header(“AMP-Access-Control-Allow-Source-Origin: ” . $domain_url);
    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    Does it work? If it does please let me know. I will look into this issue more thoroughly and include a patch in the next update.


    Sorry for the late reply – I am on vacation until next week.

    The line

    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    was missing in my file.
    I will add it next week and tell you how it went

    Plugin Author Blaz K.


    Perfect! Thank you!

    unfortunately we don’t have enough time this week – sorry. We will test it next Monday. Thx for your patience!



    Just did some tests with adding
    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    always ended in an unexpected error -> site not working anymore/plugin could not be actived.

    We will end the tests for now since we got other projects to focus on. Sorry we could not help solving this issue.

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.