Skip to content

Instantly share code, notes, and snippets.

@proframework
Created August 26, 2015 18:23
Show Gist options
  • Save proframework/e84770458c4f17b6ea64 to your computer and use it in GitHub Desktop.
Save proframework/e84770458c4f17b6ea64 to your computer and use it in GitHub Desktop.
add_action('admin_init','pro_convert_seo_values');
function pro_convert_seo_values()
{
$args = array(
'post_status' => 'publish',
'posts_per_page' => -1,
'post_type' => 'page'
);
$posts = get_posts($args);
foreach ( $posts as $post ) {
// Old values
$oldseo = get_post_meta($post->ID, '_custom_meta2', true);
$title = $oldseo['fl_meta_title'];
$desc = $oldseo['fl_description'];
$keywords = $oldseo['fl_keywords'];
// Update new values with old values
update_post_meta($post->ID, '_yoast_wpseo_title', $title);
update_post_meta($post->ID, '_yoast_wpseo_metadesc', $desc);
update_post_meta($post->ID, '_yoast_wpseo_metakeywords', $keywords);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment