Problem:
Want to build the post title for Products CPT only.
Solution:
You can use get_post_type function.
add_action('cred_save_data', 'build_post_title', 10, 2); function build_post_title($post_id, $form_data) { if ( get_post_type( $post_id ) == 'slug_post_type' ) { if ($form_data['id']==98 || 216) { $field1 = get_post_meta($post_id, 'wpcf-name-1', true); $field2 = get_post_meta($post_id, 'wpcf-name-2', true); $post_title=$field1.' + '.$field2; $slug = sanitize_title($post_title); wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug)); } } }
Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_post_type/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Noman.