Hi all. Newbie here. I searched the forum and used this code successfully to update the service post type's post_title using a custom field. How would I rewrite this to support looping through multiple custom post types (service, reviews, portfolio, etc.) and have their custom fields update that specific post type's post_title when a new post is created?
<?php
add_action("rwmb_service_after_save_post", "update_post_title");
function update_post_title($post_id)
{
// Get the field value
$my_meta = rwmb_meta("service_title", "", $post_id);
// Preprare update post
$my_post = [
"ID" => $post_id,
"post_title" => $my_meta,
];
wp_update_post($my_post);
}
Thanks in advance.