Ad

Add/update SEO Metakeywords Programmatically Of Woocommerce Product

- 1 answer

Could you tell me please, what is the best way to add/update SEO metakeywords programmatically?

i looked it up and found on this article how to update meta title and meta desc : https://ehikioya.com/how-to-update-yoast-seo-fields-programmatically/

when i tried to update the meta key words with the same code it wont work.

$updated_title = update_post_meta($post_id, ‘_yoast_wpseo_title’, $metatitle); //working
$updated_desc = update_post_meta($post_id, ‘_yoast_wpseo_metadesc’, $metadesc); //working
$updated_kw = update_post_meta($post_id, ‘_yoast_wpseo_metakeywords’, $metakeywords); // not working

I’m writing a plugin for import products and categories in WooCommerce.

Ad

Answer

I believe that Yoast SEO removed metakeywords. Searching the plugin code only title and metadesc still exist. Here is an article from Yoast explaining it Meta keywords: why we don't use them

You may instead need to try using their Focus keyword meta ie _yoast_wpseo_focuskw

Ad
source: stackoverflow.com
Ad