Automate insertion of focus keyword – Product short description

#493103
Viewing 5 replies - 1 through 5 (of 5 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with setting the WooCommerce product short description as the keyword.

    You will need to modify the code provided in the guide to retrieve the product short description as shown in the guide. Please try the code snippet below

    
    /**
     * 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'        => 'product' //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_excerpt($p->ID)));
        }
    }
    add_action('init', 'update_focus_keywords');
    

    Hope that helps. Please let us know if you have questions.

    Fredrick
    Rank Math free

    Are you sure above code is correct? Where it is updating the “product short description”

    There is no variable for “product short description” in above code.

    Fredrick
    Rank Math free

    Kindly share code snippet for “product short description”

    Fredrick
    Rank Math free

    It works… i could see excerpt…

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

You must be logged in to reply to this ticket.