Hello,
Thank you for contacting Rank Math for help with setting the WooCommerce product short description as the keyword.
You will need to modify the code provided in the guide to retrieve the product short description as shown in the guide. Please try the code snippet below
/**
* Function to automatically update the focus keyword with the post title
*/
function update_focus_keywords()
{
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'product' //replace post with the name of your post type
));
foreach ($posts as $p) {
update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_excerpt($p->ID)));
}
}
add_action('init', 'update_focus_keywords');
Hope that helps. Please let us know if you have questions.
Are you sure above code is correct? Where it is updating the “product short description”
There is no variable for “product short description” in above code.
Kindly share code snippet for “product short description”
It works… i could see excerpt…
Hello,
Glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.