• Resolved curillo

    (@curillo)


    I am using an API to create products on my website, and I am adding the keyword directly after creating each product(woocommerce). However, I have noticed that the SEO score in Rank Math does not update automatically after setting the keyword using the API.

    After completing the product creation process, I review the products and find that the keyword is properly set. However, the SEO score assigned to the products is below 30. What’s interesting is that if I click on the keyword and simply press Enter without making any changes, the score automatically increases to over 55.

    This problem is particularly relevant as I have around 5000 products, and if users manually add keywords, it would take a lot of time.

    I request your assistance in resolving this issue and ensuring that the SEO score is updated correctly after setting the keyword via the API.

    Here is the excerpt of my code:

    if ($is_creating_product) {
                set_rank_math_keywords($product_id, $product->get_name());
            }
    function set_rank_math_keywords($product_id, $keywords)
    {
        update_post_meta($product_id, 'rank_math_focus_keyword', $keywords);
        if (function_exists('rank_math') && method_exists(rank_math(), 'update_post_score')) {
            rank_math()->update_post_score($product_id);
        }
    }
    • This topic was modified 1 year, 8 months ago by curillo.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @curillo,

    Thank you for contacting the support.

    Our plugin needs to run the content analysis on your content to generate the SEO score. So using the filter to update the score will not work in this case.

    Please navigate to WP Dashboard > Rank Math > Status & Tools > Database Tools and use the Update SEO Scores tool there to update the SEO scores in bulk.

    Let us know how that goes. Looking forward to helping you.

    Thread Starter curillo

    (@curillo)

    Hello, Thank you, it works perfectly. I wouldn’t need these 3 lines of code anymore, right?

    if (function_exists('rank_math') && method_exists(rank_math(), 'update_post_score')) {
        rank_math()->update_post_score($product_id);
    }

    And an additional question, how would I update the SEO description (the one found within each product under Edit product -> Rank Math SEO -> Edit snippet -> General -> Description)? I have used: update_post_meta($product_id, '_rank_math_description', $description); but it never gets updated.

    I haven’t found any documentation or related to do this.

    Thread Starter curillo

    (@curillo)

    Hi,
    I already found the error because the description was not saved, the meta is rank_math_description if the underscore (_)
    Thank you.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @curillo,

    You don’t need those three lines of code to update the SEO score. You can remove them.

    We are glad that you were to figure out the correct meta key for the SEO description. The description should be saved without any issues now.

    Please don’t hesitate to get in touch in case you need our assistance with anything else.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SEO score does not update automatically after setting keyword via API’ is closed to new replies.