Problem:
Client uses some custom code to duplicate posts, which works correctly except for checkboxes fields. How to handle duplicating checkboxes fields onto the new posts?
Solution:
Checkboxes fields are stored as serialized arrays in wp_postmeta, and there is an anomaly with WordPress in how the value is returned by get_post_meta, depending on whether you retrieve the value of the field directly (by specifying the key), where it is returned as an array, or whether you retrieve the value of all fields at once (by not specifying a key), where it is returned as a string.
I updated the code used by the client to use the function maybe_unserialize to update the value before saving the post meta on the new, duplicated, post, as shown below: https://toolset.com/forums/topic/retain-checkbox-and-relationship-value-when-duplicate-post-on-front-end/#post-948285
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Ce sujet contient 1 réponse, a 2 voix.
Dernière mise à jour par Il y a 6 années et 4 mois.
Assisté par: Nigel.