-
Hello RankMath!!
I am using woocommerce website. My website has a 22000 products and I am working alone on my website. Out of 20000 per day I can set keyword to 10/12 products. Is there any way to insert keyword to all product page at once?
My site: https://pricepacific.com
-
function update_focus_keywords() { $posts = get_posts(array( 'posts_per_page' => 100, 'post_type' => 'product' 'offset' => 100 // Replace post with the name of your post type )); foreach($posts as $p){ // Checks if Rank Math keyword already exists and only updates if it doesn't have it $rank_math_keyword = get_post_meta( $p->ID, 'rank_math_focus_keyword', true ); if ( ! $rank_math_keyword ){ update_post_meta($p->ID,'rank_math_focus_keyword',strtolower(get_the_title($p->ID))); } } } add_action( 'init', 'update_focus_keywords' );
Is this code right?
Hello,
You need to be constantly changing the offset each time you run the code so that it can process the next batch.
After you process the first 100 you should increase the offset by the same amount, meaning that you constantly add 100 each time you process the first 100 products.
Hope this helps clarify your doubts.
Don’t hesitate to get in touch if you have any other questions.
But I don’t know how? Can you please give me code?
Hello,
What my colleague meant here is every time you execute the code (by loading the post list page), you need to change the offset again by hundreds to process and add the keywords to the next batch of 100 posts.
Example:
offset: 100
(load the page to process the first 100 post)
offset: 200
(load the page to process another 100 post)
offset: 300
(load the page to process another 100 post)
and so on until you reach 22kThis might be a repetitive task but since you can’t just process all 22k posts, you need to add the keywords by batch so your server will not use all of its hardware resources resulting in error.
You can also increase the
posts_per_page
to 200 or any higher value as long as your server can handle it. Then set the proper offset.Hope that helps you with your issue. Thank you.
Okay!! So, once 100 offset gets done then I need to increase it and make it 200. Right?
And How I know that batch of 100 is getting done?Hello,
The only way to check that is by inspecting your products in the backend of WordPress or by checking the database directly and look for the
rank_math_focus_keyword
entry in thewp_postmeta
table and making sure that the products are being updated those values.Hope this helps clarify your doubts.
Don’t hesitate to get in touch if you have any other questions.
I am not able to find this wp_postmeta table inside my database. but Yes, there is a table called wpeg_postmeta. inside wpeg_postmeta I couldn’t find anything related to rank_math_focus_keyword.
I also check with rank math tables. There are 7 tables available of rankmath.
1.)wpeg_rank_math_404_logs.
2.)wpeg_rank_math_analytics_gsc
3.)wpeg_rank_math_analytics_objects
4.)wpeg_rank_math_internal_links
5.)wpeg_rank_math_internal_meta
6.)wpeg_rank_math_redirections
7.)wpeg_rank_math_redirections_cacheHello,
It seems like the prefix of tables on your database is
wpeg_
, please look for the tablewpeg_postmeta
and see if you can find it.Please let us know how that goes.
Thank you.
I checked with the wpeg_postmeta table but there is nothing like rank_math_focus_keyword.
all I can see is _wp_attached_file and _wp_attachment_metadata repeatedly.Hello,
Inside the
postmeta
table, you will also findpost_id
andmeta_key
columns. Now, you can find the post by its ID.
e.g., you have a post, and it has the post ID87
:See the screenshot:
https://i.rankmath.com/uqwA2jNow you can look at all the metadata related to post ID like here shown in the screenshot:
https://i.rankmath.com/zcq44GHope that helps and please do not hesitate to let us know if you need our assistance with anything else.
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 ‘Can I set bulk keywords?’ is closed to new replies.