-
How to set auto focus keyword fill? I have 5000+ items in my website and i want to make the keyword for every item as %title% how can i do that?
-
Hello,
Thank you for contacting Rank Math.
You can use this code in WordPress > Appearance > Theme Editor > functions.php to automatically use the post title as the focus keyword:
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' );https://rankmath.com/kb/how-to-automate-the-insertion-of-focus-keyword/
I hope this helps. Looking forward to helping you.
that is not a post, i have a few custom post types with name “movies” “tv shows” “seasons” “episodes”
Oh nvm, i found it.
One more question. I need to write the same function 4 times, i did first, it was all ok, but for second it is not working.
function update_focus_keywords1() {
$posts = get_posts(array(
‘posts_per_page’ => -1,
‘post_type’ => ‘tvshows’ //replace post with the name of your post type
));
foreach($posts as $p){
update_post_meta($p->ID,’rank_math_focus_keyword1′,strtolower(get_the_title($p->ID)));}
}
add_action( ‘init’, ‘update_focus_keywords1’ );And also in my post types it is not displaying the rank, i have to publish to see the score here
https://imgur.com/a/rXLHB5WHello,
Thank you for keeping in touch with us.
It is normal to see “N/A” in the post/page list. The scoring script only runs when you open a post. Please open a post, make changes, see the correct score, save the page. The score will then propagate to the Post List view as well.
Note that this will not affect your actual SEO settings on your front page.
Unfortunately, there is no way to automate this. We would not suggest automating that anyway.
Some of the tests only run when you load up a post. The score gets saved when you hit the update button. But, don’t just hit the update button without changing any content on your website. If you do this, Google will think you are trying to manipulate the date Google sometimes shows beside your search result (https://i.rankmath.com/BiZDrV)
So, we recommend that you start with your most important posts, open then, make changes as per recommendations made by Google and then hit the update button.
As for the issue regarding the functions, can you please share your WordPress admin login so I can further check it? Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
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,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
Thanks for your reply.
I logged into your website’s admin area and upon inspecting, I found that the post type field in the function was set as
tvshowswhereas the name of the CPT istv shows(with space in between).So, I went ahead and made the required changes and the function is now working as expected. Please have a look at the screencast available in the sensitive data section of this ticket and confirm it on your end.
Looking forward to hearing from you.
Thanks.
thank you.
can you please check the code again? it is working for seasons, but not for episodes. the code i added
Hello,
Thank you for keeping in touch with us.
I checked the code and it seems to be in the wrong format. I tried adjusting the code but it won’t let me as I am greeted with an error.
Can you please share your FTP instead?
We are looking forward to helping you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
i submitted
Hello,
Thank you for the update, and apologies for the delay.
I’ve checked the link you have provided, and the login credentials are working. However, it seems that the site is for your domain management. Could you please walk us through how to get to your file manager from there?
Your site also has a direct link which is
/cpanel, but the login credentials are not working there.Thank you, and looking forward to your update.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
Thanks for getting back to us.
When I checked the code was commented out on your website so it wasn’t running for sure.
Now, when uncommented it and tried to run it I ran into some issues that might be because you have a lot of entries, and changing all the focus keywords from the CPTs is causing your server resources to run out.
We recommend the following values in your server variables:
PHP Memory Limit: 512M
Max input time: 150
PHP time limit: 120
PHP max input variables: 1000Please update your server to at least the following values and then report back so we can test run the code once again.
Looking forward to hearing back from you.
I have updated values
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.
The ticket ‘How to set auto focus keyword fill?’ is closed to new replies.