This support ticket is created Il y a 7 années et 6 mois. There's a good chance that you are reading advice that it now obsolete.
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hi,
I have a Many to many relationship setup for Artist and Exhibitions. I did create a Custom Post Type to manage many relationship but when my post are generated I got a generic naming "rel-artist-expo-20"
I would like to be able to customize the name used for those posts with one of my post fields or a title from Artist/expo CPT, or a mix of both, so that there is a more visual relationship between them.
Could you please guide me to accomplish it?
Thanks
Hello. Thank you for contacting the Toolset support.
There is no native solution available to change the post title name but you may try to do that using the custom code and use "save_post" action hook in order to update the your CPT's title.
Unfortunately, custom programming work is out of the scope of our support polity but If you need custom programming for your site, please don't hesitate to contact our certified partners:
=> https://toolset.com/consultant/
Hi,
Thanks for your answer I know how to do the WordPress part but i miss how to get data from the toolset.
How can a get the date of the child CPT?
How can I get a specific Field from a group of the child Post Type?
I think this should be a nice feature to have, naming by numbering is not really usefull
Thanks!
function modify_post_title( $data )
{
if($data['post_type'] == 'rel-artista-expo' && isset($_POST['expo_date'])) {
$artistname = get_post_meta($post->ID, 'artistname'); // how can I get a field from a child
$date = date('l, d.m.Y', strtotime($_POST['expo_date'])); // data is not stored and only get Thursday, 01.01.1970 Unix timestamp first day
$title = $date . ' Expo ' . $artistname;
$data['post_title'] = $title ; //Updates the post title to the new title.
}
return $data; // Returns the modified data.
}
Great!
But I need the parent, as I said I'm trying to change the title of the CPT for a Many to Many relationship.
Can you point me to the same resource but for a parent? Please 🙂
I did try to find it in the API reference but could'nt
Thanks for your time
I'm guessing that $child_post_id should be used in the loop because I get Undefined variable: child_post in /Applications/MAMP/htdocs/...
What is $child_post_id?
Right now my function is re-writing the title and I'm just trying to get the parent ID and add it the title, but I can't because of $child_post_id is Undefined
Does this make any sense?
// Grabs the inserted post data so you can modify it.
add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 1 );
function modify_post_title( $data )
{
if($data['post_type'] == 'rel-artista-expo' ) {
$parent_id = get_post_meta($child_post_id, '_wpcf_belongs_{exposiciones}_id', true);
$title = 'Expo_' . $parent_id;
$data['post_title'] = $title ; // Updates the post title to the new title.
}
return $data; // Returns the modified data.
}
2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.