-
Hello ,
I added to functions.php this code , but it doesnt work. I cleared cache from cloudflare and localy , i also tried to add it to rank-math.php but still no luck
/**
* Add <meta name=”keywords” content=”focus keywords”>.
*/
add_filter( ‘rank_math/frontend/show_keywords’, ‘__return_true’);Also this one doesnt work too .
/**
* 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’);Thank you !
The ticket ‘Frontend keyword’ is closed to new replies.