Hello,
Thank you for contacting Rank Math.
Here is a code that will loop your posts and insert a keyword from the post type’s title:
function update_focus_keywords() {
$posts = get_posts(array(
'posts_per_page' => -1, /* -1 will retrieve all post type */
'post_type' => 'post' /* post, page, product */
));
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' );
Do note that this configuration will loop ALL your post. Modify this code as per your preferences.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Now it´s working. Good job. And big thanks. You are the best!!!
Hello,
We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.
If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.