Problem: I have a CRED form that allows users to create child posts. Using cred_save_data, I would like to create a custom post title using information stored in a custom field on the parent post.
Solution: In cred_save_data, you will be able to determine the parent post's ID using get_post_meta to access _wpcf_belongs_parentslug_id. Then you can get the custom field value using get_post_meta, the parent ID, and the custom field slug:
... // get the parent ID from the child postmeta $parent_id = get_post_meta($post_id, '_wpcf_belongs_parentslug_id', true); // get the title from the parent postmeta $custom_title = get_post_meta( $parent_id, 'wpcf-custom-field', true ); ...
Relevant Documentation: https://developer.wordpress.org/reference/functions/get_post_meta/
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Ce sujet contient 4 réponses, a 2 voix.
Dernière mise à jour par Il y a 7 années et 3 mois.
Assisté par: Christian Cox.