Tell us what you are trying to do? I have a custom post type called Alumni Memorials. I need to create something that will not need a title (if there is a way to autogenerate that is good).
Here is an example of what the page should like like. hidden link
Even if there was a way to make the title first_name last_name cast_year automatically that would work. I just don't want them to enter that in the title since the order etc. will be messed up.
Is there any documentation that you are following? NO
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Well - I would like to know first from where you are adding the posts for post type "Alumni Memorials". Are you adding post from admin or front-end?
From where we can get these field values using which you would like to build the dynamic/automatic title such as first_name last_name cast_year.
Everything is backend. As I mentioned, it's a custom post type. All the fields are custom fields.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - you need to use WordPress action hook: save_post
You need to add the following code to your current theme's functions.php file. For example:
function update_venue_concert( $post_id ) {
$post_type = get_post_type($post_id);
if ( "concert" != $post_type ) return;
$strAllBandList = 'something' . rand(10,100);
$strConcertTitle = 'CTitle' . rand(10,100);
$newslug = str_replace('@','at', $strAllBandList);
write_log('new slug: ' . $newslug);
$my_post = array(
'ID' => $post_id,
'post_title' => $strConcertTitle,
'post_name' => $newslug
);
remove_action('save_post', 'update_venue_concert',20,3);
wp_update_post($my_post);
add_action( 'save_post', 'update_venue_concert',20,3);
}
add_action( 'save_post', 'update_venue_concert',20,3);
You can adjust above code as per the need with post type slug and other information.
The related ticket that may help you:
=> https://toolset.com/forums/topic/save_post-with-a-wp_update_post-is-clearing-all-radio-and-checkbox/#post-475158
More info:
=> https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/