Updating Yoast keywords dynamically
-
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.
- The topic ‘Updating Yoast keywords dynamically’ is closed to new replies.