Sauter la navigation

[Fermé] Change modified date when relationship change

This support ticket is created Il y a 4 années. 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.

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Nigel Il y a 4 années.

Auteur
Publications
#1905025

Hello!

I have a custom type with multiple relationships.
I would need the modified date of the custom type to be updated when the related custom types are updated.

how i can do this?
thanks

#1905441

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

You would need to use custom code to achieve this.

You can use the WordPress save_post hook (or, probably better, the more specific hook for your particular post type: https://developer.wordpress.org/reference/hooks/save_post_post-post_type/) to initiate the code whenever a post is updated.

Then use the toolset_get_related_posts API function to get an array of posts that are connected to the post that has been updated.

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Then for each of these posts use wp_update_post to update the post so that the modified date is changed.

https://developer.wordpress.org/reference/functions/wp_update_post/

Le sujet ‘[Fermé] Change modified date when relationship change’ est fermé à de nouvelles réponses.