-
Hello, I add this code in rank-math.php and is allright
————————————————————–
<?php
/**
* Function to automatically update the product focus keyword with the product category
*/
function update_product_focus_keywords()
{
$products = get_posts(array(
‘posts_per_page’ => 100,
‘post_type’ => ‘product’ //replace post with the name of your post type
));
foreach ($products as $p) {
$keywords = [];
if (get_the_terms($p->ID, ‘product_cat’)) {
foreach(get_the_terms($p->ID, ‘product_cat’) as $term) {
$keywords[] = strtolower($term->name);
}
update_post_meta($p->ID, ‘rank_math_focus_keyword’, implode(“, “, array_unique($keywords)));
}
}
}
add_action(‘init’, ‘update_product_focus_keywords’);
——————————————————————-My problem: I need to add NAME of Product, NO category product in focus keyword.
Thank yoy very much
The ticket ‘Change category to titke product in focus keyword’ is closed to new replies.