SEO score does not update automatically after setting keyword via API

[ad_1]

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 4 hours, 33 minutes ago by curillo.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer