using product title as keywords – Automation

#633321
  • Resolved Anonymous
    Rank Math free

    Hello,
    I use following code in Functions.php or rank-math.php but it doesn’t work, no keyword will be added after product update :

    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){
    // 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’ );

    Any idea ?
    Kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Anonymous
    Rank Math free

    It seems it only works when it’s added to Functions.php not rank-math.php !

    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.

    Could you please share the screenshot of your rank-math.php code so we can check as well? You can upload screenshots using this tool and add the generated link here.

    Meanwhile, please ensure that you have included the PHP opening tag <?php. It should look like this when applying it via the rank-math.php file (notice the first line)

    opening

    Looking forward to helping you.

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

The ticket ‘using product title as keywords – Automation’ is closed to new replies.