post title as focus keyword

#351313
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.

    If you have a very high number of posts, the function can cause such issues.

    To fix this, you can add an offset and define the number of posts to be processed at once and this should fix the issue.

    Here’s a code that you can use to set the post tag as the focus keyword with an offset value:

    /**
     * Function to automatically update the focus keyword with the post tags
     */
    function update_focus_keywords()
    {
        $posts = get_posts(array(
            'posts_per_page' => 1000,
            'post_type' => 'post' //replace post with the name of your post type
            'offset' => 0 // Increase this by 1000 each time.
        ));
         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');

    Please make sure to remove the previously used code to add the focus keyword. Also, make sure to increase the offset value by 1000 each time you run the code.

    The above function adds the focus keyword to 1000 posts at once (‘posts_per_page’ => 1000).

    Please let us know how that goes.

    Thank you.

    Buzz Munky
    Rank Math free

    I have only 25 posts at the moment. Will this cause an issue?

    Hello,

    If you only have 25 posts then the normal filter shouldn’t cause any issues.

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    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,

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘post title as focus keyword’ is closed to new replies.