Hello @jaworowicz
Thank you for contacting the support.
Instead of adding it from the SQL, you can do it from the functions file by using get_posts()
function and update the post meta in the loop using
get_post_meta()
to get the description value from the meta key and updating it using update_post_meta( $post->ID, 'rank_math_description', $desc )
Hope that helps. If you have any further question(s), please let us know.
But how move 5000 meta from “my_post_desc_meta” to “rank_math_description”
Hello @jaworowicz
Please take a complete backup before running the following query:
$posts = get_posts( array(
'posts_per_page' => 100,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'rank_math_description',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'rank_math_description',
'value' => '',
'compare' => '='
),
)
)
);
foreach( $posts as $post ) {
$description = get_post_meta( $post->ID, 'my_post_desc_meta', true );
update_post_meta( $post->ID, 'rank_math_description', $description );
}
You can use this in init hook or wp hook. You will have to run this multiple times as posts_per_page only gets first 100 posts.
Hope that helps. Thank you.