I would like to have my child "Training" custom type URL be under the parent "Course" URL.
hidden link;
e.g. hidden link hidden link
Details:
I do not believe there is a way to do this out of the box with Toolset. (If there is then please let me know)
I believe that I can leverage the Permalink Manager plugin to add any fields on a custom post type to the Permalink structure.
New Permalink for Training: training/courses/__parent_slug/%trainings%/
For this to work the "Training" post type would need to have a custom field that holds the slug from the parent "Course" type. I would like to add some PHP using the Snippet plugin to my site that populates a custom field called "parent_slug" to any post type that has a parent added.
Question 1:
Is there a way to hook into the "add relationship" event so that I can update this field when the relationship is added?
Question 2:
How do I parse the parent work item to get its data when doing the update to the "training".
note: no access to our environment is required, nor will be provided, to answer these questions about toolset, its features, and its API.
Hello. Thank you for contacting the Toolset support.
What if you try to use the Toolset hook "toolset_association_created" and add your desired custom code to update the value of your custom field:
add_action( 'toolset_association_created', 'func_update_child_custom_field', 10, 5 );
function func_update_child_custom_field( $association_slug, $parent_id, $child_id, $intermediary_id, $association_id ) {
// Check against the post reference field slug.
if ( $association_slug == "your-post-relationship-slug" ) {
// execute the code to update the post's title
}
}
Where:
- Replace "your-post-relationship-slug" with your original post relationship slug
My issue is resolved and support was awesome. I ended up using the linked examples to create both a "toolset_association_created" and a "Cron" job to populate this data...