• Resolved rokasgl

    (@rokasgl)


    Hi.

    I’m trying to update my products keywords dynamically with running this script:

    <?php /* Template Name: SEO */ ?>
    <?php
    error_reporting(E_ALL);
    ini_set(‘display_errors’, 1);
    //ini_set(‘memory_limit’, ‘512M’)
    $posts_query = new WP_Query(
    array(
    ‘post_type’ => ‘product’,
    ‘posts_per_page’ => -1
    )
    );

    while($posts_query->have_posts()) : $posts_query->the_post();
    $title = get_the_title();
    $post_id = get_the_ID();

    update_post_meta($post_id, ‘_yoast_wpseo_focusk??w’, $title);

    echo $title . ‘ Meta Updated<br />’;
    endwhile;
    ?>

    It runs successfully, but focus keyphrases inputs are empty. When I’m trying to close the edit product page without changing anything, everytime it shows “Leave Site? Changes you made may not be saved.” pop-up in chrome.

    And now I can’t even save keyphrases manually. After pressing update product button, page reloads and keyphrase disappears.

    What am I missing ?

    This method worked 2 years ago.

    • This topic was modified 4 years, 1 month ago by rokasgl.
    • This topic was modified 4 years, 1 month ago by rokasgl.
Viewing 1 replies (of 1 total)
  • Hi @rokasgl,

    Since version 14.0, there’s been a change and the data Yoast SEO uses for posts comes from the Yoast indexables tables. There’s more details in the 14.0 release post.

    If you haven’t done so already, can you make sure you’ve updated to 15.7 and then go to SEO?> Tools? Under “Optimize SEO Data”, please click the “Start SEO data optimization” button.

Viewing 1 replies (of 1 total)
  • The topic ‘Updating Yoast keywords dynamically’ is closed to new replies.