Error doing “Automate the Insertion of Focus Keyword”

#451004
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    You can limit the number of posts that you process each time is by setting a limit on the posts like so:

    'posts_per_page' => 100
    

    You can then add an offset to the function as well to continue adding the focus keywords to newer posts. So, after changing the first 100 posts you add an offset of 100 to the function like so:

    'offset' => 100
    

    You can continue to increase the offset by 100 until it runs through all of the posts.

    Each time you run the function, you can add 100 to the offset value like,

    1st time : 'offset' => 0, 
    2nd time : 'offset' => 100,
    3rd time : 'offset' => 200,

    And so on…

    I hope that helps.

    Thank you.

    your method worked. I had to do ‘posts_per_page’ => 1000. my server couldn’t load -1 posts because it has over 40k posts. I followed your “offset” solution and all of my posts had the focus keyword. but i would like to know if it will add focus keywords automatically in my new post or not? because to add in the previous posts, I had to reload my post page each time to add the focus keyword.

    $posts = get_posts(array(
    ‘posts_per_page’ => 100,
    ‘post_type’ => ‘post’, //replace post with the name of your post type
    ));

    this is what I am using right now, without offset.

    Hello,

    This will not add the focus keywords to new posts as it’s only designed to update the focus keyword on older posts.

    After doing that for all the older posts, when creating new ones you can add the focus keyword yourself when writing the posts which is the normal workflow.

    Don’t hesitate to get in touch if you have any other questions.

    hi, I tried and it actually added Focus Keyword on new posts too. that’s a relief. I would like to ask another question that is not directly related to this Ticket Topic.

    I publish posts on my WordPress site using WordPress REST API. but I am unable to add “rank math focus keyword” metadata using REST API. I tried many methods but non of them worked. tried googling too. I’m using python to do it. followed some instructions too. still not working. the keyword doesn’t get published along with the post, it stays blank(not set). it would be great if you can instruct me on this.

    Hello,

    The focus keyword field is simply a metadata field inside the default postmeta database table so it can be created like you would usually do for any other postmeta entry.

    This article explores this idea a little bit more: https://mklasen.com/updating-custom-post-meta-via-the-wordpress-rest-api/

    Don’t hesitate to get in touch if you have any other questions.

    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.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Error doing “Automate the Insertion of Focus Keyword”’ is closed to new replies.