Hello, I’m sorry to hear that you’re experiencing an issue with changing the focus keyword from the category name to the post title. To automatically update the focus keyword with the post title, you can add a code snippet to your theme’s functions.php
or rank-math.php
file. Here’s the code snippet you can use:
/**
* 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');
Please note that this code will replace all your existing focus keywords. If you wish to set the post title as a focus keyword only for the posts that don’t have a focus keyword set, then use the following code instead:
/**
* Function to automatically update the focus keyword with the post title for posts without a focus keyword set
*/
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) {
if (!get_post_meta($p->ID, 'rank_math_focus_keyword', true)) {
update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_title($p->ID)));
}
}
}
add_action('init', 'update_focus_keywords');
You can add this code to your theme’s file editor and save the changes. This should help you automatically update the focus keyword with the post title. If you have any further questions or need assistance, please feel free to reach out to our support team here.
Sources:
How to Automate the Insertion of Focus Keyword » Rank Math
Bulk Editing Options in the Rank Math SEO Plugin
Why Can’t I Enter More Than 1 Focus Keyword in Post and Product Categories? » Rank Math
Hello,
In this case, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
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.