Problem:
Automatically populate a Custom Post Type Title with a Custom Field
Solution:
You can use the WordPress standard hook "save_post" to override the post title.
For example:
function is_project_overdue( $post_id, $post ){ global $wpdb; if ( 'your-post-type-slug' == $post->post_type ) { $custom_title = "cutom title goes here"; // adjust your custom title value here $wpdb->update( $wpdb->posts, array( 'post_title' => $custom_title ), array( 'ID' => $post_id ) ); } } add_action( 'save_post', 'is_project_overdue', 30, 2 );
Where:
- Replace your-post-type-slug with your original post type slug
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 1 month ago.
Assisted by: Minesh.