Saltar navegación

[Cerrado] Change modified date when relationship change

This support ticket is created hace 4 años. 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.

Etiquetado: 

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Nigel hace 4 años.

Autor
Mensajes
#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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: 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/

El debate ‘[Cerrado] Change modified date when relationship change’ está cerrado y no admite más respuestas.