$parent_id = 111; // adjust your parent post ID here
$taxonomy_slug = 'book-type';
$parent_terms = wp_get_object_terms( $parent_id ,$taxonomy_slug);
if(!empty($parent_terms)) {
foreach($parent_terms as $parent_term) {
//// do whatever you want
}
}
Where:
- Replace 'book-type' with your original taxonomy slug.
This is really helpful, and I can see how this can work.
However, this presupposes that there is a known $parent_id, but this would change from post to post. How can I get the $parent_id from the current post? I've been looking at the Programmer Documentation, but I can't seem to find this.
I have two post_types, called Awards ($post_type = 'award') and Award Recipients ($post_type = 'award-recipient'). 'award' has the name of the Award and various general information. The Award Recipient is the person that receives the award, so has name, year of award, etc. There is a (one to many) relationship between Award and Award Recipient.
We don't know the parent_id of the Award, as there may be many awards and many recipients. So, for the code you have shown me, I need a way to get the parent_id from the 'award'.
I would like to know - at what course of action you want to generate the post title automatically?
Are you using Toolset form? if yes - Can you please tell me on what page/post you added the Toolset post form?
*** 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 have set the next reply to private which means only you and I have access to it.