Advanced automation package of posts

#961345
  • Resolved Jeapy
    Rank Math free

    Hi,
    is it possible to set up an advanced automation to automatically choose >> extract then place focus keywords in SEO fields for daily imported package of several posts in the same time (imported posts via gateways) ?
    Thank you.
    Best Regards

Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the issue you are facing. Currently, Rank Math does not have a built-in feature specifically designed for advanced automation of focus keywords for bulk imported posts via gateways. However, you can automate the insertion of focus keywords using custom code snippets as described in our knowledge base articles.

    For instance, you can use the following code snippet to automatically set the focus keyword based on the post title or tags:

    Automatically Use the Post Title as the Focus Keyword

    /**
     * Function to automatically update the focus keyword with the post title
     */
    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');

    Automatically Use Post Tags as Focus Keywords

    /**
     * Function to automatically update the focus keyword with the post tags, if no focus keyword is set
     */
    function update_focus_keywords() {
        $posts = get_posts(array(
            'posts_per_page' => 100,
            'post_type' => 'post' //replace post with the name of your post type
        ));
        foreach ($posts as $p) {
            $keywords = [];
            if (get_the_tags($p->ID)) {
                foreach ((get_the_tags($p->ID)) as $tag) {
                    $keywords[] = strtolower($tag->name);
                }
                if (!get_post_meta($p->ID, 'rank_math_focus_keyword', true)) {
                    update_post_meta($p->ID, 'rank_math_focus_keyword', implode(", ", array_unique($keywords)));
                }
            }
        }
    }
    add_action('init', 'update_focus_keywords');

    You can add these snippets to your theme’s rank-math.php file. Please note that these snippets will replace existing focus keywords if not modified accordingly.

    For more detailed instructions, you can refer to our article on How to Automate the Insertion of Focus Keyword.

    If you have further questions or need assistance with specific implementations, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Thank you for raising this concern!

    Sources:
    How to Automate the Insertion of Focus Keyword » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

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

The ticket ‘Advanced automation package of posts’ is closed to new replies.