Meta Box
Support › General › Post title and custom fieldResolved
Hi, I followed these directions https://support.metabox.io/topic/change-title-to-custom-field-using-rwmb__before_save_post-action/ but i can't solve.
I would like to save a custom post with the title post taken from a custom field. id field is text_f71tmmr7ws meta box ID is gruppo-campi-pazienti-orto.
Please help me 🙂
Hi Mariano,
In your case, the code should be
add_action( 'rwmb_gruppo-campi-pazienti-orto_after_save_post', 'update_post_title' ); function update_post_title( $post_id ) { // Get the field value $my_meta = rwmb_meta( 'text_f71tmmr7ws', '', $post_id ); // Preprare update post $my_post = array( 'ID' => $post_id, 'post_title' => $my_meta, ); wp_update_post( $my_post ); }
Let me know how it goes.
Hi Ya Long
Where do I find my Metabox ID to put in this code - i can find field ID's fine but cant seem to find a metabox ID
Hi Warren,
The Meta Box ID is the field group ID if you use the builder to create the custom fields. Screenshot https://monosnap.com/file/Rav02VuuBnPyZuAb3sY05sT36PpSiV