-
/**
* 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' => 'post' //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_title($p->ID)));
}
}
add_action('init', 'update_focus_keywords');every time I try to Automate the Insertion of Focus Keyword using the code above and uploading it on the function.php it’s breaking my website, How do we change that? Im using the WP bootstrap starter theme
The ticket ‘Automatically Use the Post Title as the Focus Keyword code is breaking my site’ is closed to new replies.