Your problem is pretty complex. Without getting into your system it’s pretty tough to solve it. For your case I would prefer to run database query but it’s seemed too complex to me. By the way here I’ve tried to write a simple PHP
script-
function the_dramatist_get_post_by_title( $page_title, $post_type="post" ) {
global $wpdb;
$post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type));
if ( $post )
return $post;
return null;
}
function the_dramatist_bulk_copy_c_fields() {
$c_posts = wp_list_pluck( get_posts(array(
'post_type'=>'catalog',
'posts_per_page' => -1
)), 'ID' );
foreach($c_posts as $c){
$title = get_the_title( $c );
$s_id = the_dramatist_get_post_by_title( $title, 'services');
$meta_value = get_post_meta( $s_id, 'price', true );
add_post_meta( $c, 'price', $meta_value );
}
return true;
}
add_action('init', 'the_dramatist_bulk_copy_c_fields');
Run the script only once. I haven’t got the chance to test it. So please test it before using it in production.
Hope that helps.