Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
The filter is returning a 500 error because you have a lot of posts and your site’s resources are not able to handle the process. Please use the following filter instead:
function update_focus_keywords() {
$posts = get_posts(array(
'posts_per_page' => 1000,
'offset' => 1000,
'post_type' => 'post' // Replace post with the name of your post type
));
foreach($posts as $p){
// Checks if Rank Math keyword already exists and only updates if it doesn’t have it
$rank_math_keyword = get_post_meta( $p->ID, 'rank_math_focus_keyword', true );
if ( ! $rank_math_keyword ){
update_post_meta($p->ID,'rank_math_focus_keyword',strtolower(get_the_title($p->ID)));
}
}
}
add_action( 'init', 'update_focus_keywords' );
This code will add the focus keyword for 1000 posts at once. Please make sure to increase the offset value by 1000 each time you run the code.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.