Hello,
Could you please confirm if where do these 4 keywords will be coming from? To add additional keywords you can follow the logic from this example filter: https://rankmath.com/kb/how-to-automate-the-insertion-of-focus-keyword/#automatically-use-the-tags-as-the-focus-keyword
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello Jeremy,
I think the best option would be to set up those 4 keywords automatically by me. In other words, all the posts within the specific post type would have 1 title keyword + 4 the same keywords. Would it please be possible? Thank you.
Best
Tomas
Hello,
I’m not sure if I fully understand your last reply.
Could you please confirm what you mean by “automatically by me”? Are you suggesting that only one keyword would be set by the code and you would manually set the rest of the keywords?
Looking forward to hearing back from you.
Thank you.
Hi Prabhat,
Sorry for the confusing explanation.
What I meant is simply that one keyword would be the title and the remaining 4 keywords would be the same (set in advance) for all the posts. Thank you.
Best
Tomas
Hello,
Just to confirm, the remaining 4 keywords would be inserted manually and you only want the keyword with the title to be inserted automatically with the code? or do you wish to apply the same 4 keywords to all the posts?
Looking forward to hearing back from you.
Thank you.
Hi Prabhat,
I wish those 4 keywords to be set automatically for the same custom post type 🙂 Thank you.
Best
Tomas
Hello,
Thank you for your patience and for the additional information.
To add the current title and 4 additional keywords to every post, you’d nedd to modify the function we previously gave you as shown below:
add_action( 'save_post', 'rm_set_save_post_title_focus_keyword',10,3 );
function rm_set_save_post_title_focus_keyword ( $post_id, $post, $update ){
$accepted_post_types = ['roles-find', 'roles-offer', 'locations', 'equipment', 'portfolio'];
if (in_array( get_post_type( $post_id ), $accepted_post_types)){
$focus_keyword = get_the_title($post_id);
$saved_keywords = strtolower($focus_keyword.",keyword1,keyword2,keyword3,keyword4");
update_post_meta($post_id,'rank_math_focus_keyword',$saved_keywords);
}
}
You would need to replace keyword1, keyword2, keyword3, keyword4 with your comma separated keywords/phrases.
Hope that helps.
Hi Nigel,
Thank you so much, that is brilliant!
Could I please ask you to double-check the code after me? I’ve tried to implement it but I receive the following error message. Thank you very much.
Best
Tomas
Hello,
It seems that the double quotes are not being parsed properly on that line. Please try removing them and manually adding the double quotes yourself in place of the ones pasted from the code.
Hope this helps solve your issues.
Don’t hesitate to get in touch if you have any other questions.
Hello Miguel,
I can confirm that after pasting the double quotes again it finally worked. Also, the code works as I’ve tested that. Therefore, I’d like to thank you and all your colleagues who helped me in resolving this. Thank you so much and wish you a good day! 🙂
Best
Tomas
Hello,
We are super happy that this resolved your issue.
If you don’t mind me 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 do 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.