Navigation überspringen

[Geschlossen] Change modified date when relationship change

This support ticket is created vor 4 Jahren, 1 Monat. 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.

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Nigel vor 4 Jahren, 1 Monat.

Author
Artikel
#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

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: 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/

Das Thema „[Geschlossen] Change modified date when relationship change“ ist für neue Antworten geschlossen.