Hello,
Thank you for contacting Rank Math support and bringing your concern to our attention.
As much as we would like to help improve the automation code we have provided, unfortunately, we don’t offer customized filters as it is already outside the scope of our support.
In our existing filter, you can simply modify the update_post_meta with “how to” being concatenated like so:
...
update_post_meta($p->ID, 'rank_math_focus_keyword', 'how to ' . strtolower(get_the_title($p->ID)));
...
You can do the same with “easily” by appending it.
With that said, we can’t offer further modifications as this is a very specific feature.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
I do not risk to delete the keywords already existing with your code, but only to add in addition to those existing, and this for all the posts is it correct?
If not, I think it’s a pity that my problem is only half solved. Who could answer the other part of my first post if you are not able to do it? I am willing to take out a yearly subscription if you guarantee that you will find a solution.
In any case I thank you for your work and your quick answer.
Hello,
Yes, the current filter shown on our guide is targeted to posts. You may also target it to post types like ‘page’ or other custom post types.
You just need to set the post_type key.
If you wish to modify an existing keyword, you need to retrieve the keyword first by calling its meta key.
...
$old_kw = get_post_meta($p->ID, 'rank_math_focus_keyword', true);
$new_kw = 'How to' . $old_kw . ' easily';
...
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Could you please direct me to a person or company that will help me with the second part of my question
Hello,
Are you referring to the question below?
2)
Is it possible to add a keyword at the end of the title.
Let’s take the examples mentioned above
Is it possible to have a code to add to the files functions.php (or other way preferably without plugin), which allows to transform the keywords :
“lose weight by eating” into “how to lose weight by eating easily”
Or for example:
“grow fast” into “how to grow fast easily”
To add the focus keyword to the end of a title, you can add the %focuskw% variable. To add this setting, go to Rank Math > Titles & Meta > Post type and in “Single Post Title” add %focuskw%

Hope that helps. Please let us know if you have questions.
That doesn’t really answer my question, no big deal. I am finally looking for a code that allows me to add in addition to the main keyword all suggestions that automatically resemble it, can you help me with this?
thank you
Hello,
Can you please share your code here so we can take a closer look at the progress you made? You may share it using this tool: https://pastebin.com/
Looking forward to helping you on this one.
I need your help for that. Indeed, I am looking for a code that allows me to add in addition to the main keyword, all the suggestions that are similar to it automatically, can you help me?
thanks
Hello,
Please try this modified automation code on your end:
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) {
$initial_kw = strtolower(get_the_title($p->ID));
$new_kw = $initial_kw;
if(trim($initial_kw) != ''){
if (!str_contains(strtolower($initial_kw), 'how to')) {
$new_kw = 'how to ' . $initial_kw;
}
if(!str_contains(strtolower($initial_kw), 'easily')){
$new_kw = $new_kw . ' easily';
}
}
update_post_meta($p->ID, 'rank_math_focus_keyword', $new_kw);
}
}
add_action('init', 'update_focus_keywords');
This should only edit the title text and insert the how to and easily texts before inserting it as your post’s keywords.
Let us know how that goes.
Looking forward to helping you.
Hello,
I apologize but in order to avoid any SEO problems, finally what exactly will the code that is your last post?
Thanks for your support.
Hello,
The code in our previous reply does the following:
Checks if the current title has the words ‘how to’ or ‘easily’ If the title has those words it is skipped/left unchanged. If it does not have those words, they are added to the beginning of the title.
Hope that helps. Please let us know if you have questions.
Thank you for your quick answer. Is it possible to add to all the posts without keywords, but also in addition to the main one to all those who already have a keyword, to add “how” at the beginning of the title and “easily” at the end of the title?
Thanks
Hello,
Unfortunately, this specific feature now falls outside the scope of our support. You may need to hire a developer to build the logic you need in our filter code.
Please do not hesitate to let us know if you need our assistance with anything else.
Thank 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.