-
I have a problem with the automation for the focus keyword, i used this script to add the tags as focus keyword:
/**
* Function to automatically update the focus keyword with the post tags
*/
function update_focus_keywords()
{
$posts = get_posts(array(
‘posts_per_page’ => 100,
‘post_type’ => ‘post’ //replace post with the name of your post type
));
foreach ($posts as $p) {
$keywords = [];
if (get_the_tags($p->ID)) {
foreach ((get_the_tags($p->ID)) as $tag) {
$keywords[] = strtolower($tag->name);
}
update_post_meta($p->ID, ‘rank_math_focus_keyword’, implode(“, “, array_unique($keywords)));
}
}
}
add_action(‘init’, ‘update_focus_keywords’);
The ticket ‘i added the script to make the automation for the focus keyword’ is closed to new replies.