Skip Navigation

[Resolved] Prevent child post from automatically updating when parent post is updated

This support ticket is created 8 years, 2 months ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 10:00 8:00 – 14:00 8:00 – 14:00 8:00 – 12:00 -
- 13:00 – 18:00 11:00 – 18:00 15:00 – 18:00 15:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Pacific/Pago_Pago (GMT-11:00)

This topic contains 7 replies, has 3 voices.

Last updated by gaborN 8 years, 1 month ago.

Assisted by: Mladen Andrejic.

Author
Posts
#368268
parent and child timestamps.png

I am trying to:
Update a parent post type, without any child post types automatically being updated

I expected to see:
The timestamp of my parent post type would change to the current time, when it is manually edited in the backend, but the timestamp of any child post types that belong to this particular parent should NOT change

Instead, I got:
The timestamp of the parent post type, and all of its children, changed to the exact same value.

1. What WordPress hook is Types/Views using to automatically update child post's timestamp when the parent post is updated?
2. In Types/Views, which PHP file, and what Class within that file, contains the code that tells WordPress to automatically update all child post's timestamp whenever their parent post is updated?
3. Is there a way to prevent child posts from automatically having their timestamps updated whenever their parent post is manually updated?

#368435

Hello,

Thanks for contacting Toolset Support. I just tested this and it doesn't happen on my install.

Can you please do some tests :

1. Check if the problem persist when :

- All non Toolset Plugins are disabled
- Theme is set to default Twenty Fourteen

2. Activate WordPress debug.log and see if there are any errors displayed? Here are the instructions for activating it : https://wpml.org/documentation/support/debugging-wpml/

3. You can also check the Chrome built-in JavaScript Console for errors. To open the console go to Menu (Three Bars) > Tools > JavaScript Console

Please paste here any errors that you see in the WordPress debug.log or in JS Console.

Thanks.

#369924

Hello

We found this function in types/embedded/includes/post-relationship.php

function wpcf_pr_admin_save_post_hook( $parent_post_id ) {

It looks like it's hooked to save_post and saves all the children of the parent post that is being saved. In the comments there's this line: remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 11);

So that's what we're testing now, to see if that indeed prevents child posts from being updated when parent posts are saved.

#370200

Hello,

I checked the code and it seems that you're right about this action. Can you please test and give me the results of it?

Thanks.

#372723

FYI, we're still testing this. At first it seemed like our fix worked fine, but now I see the issue recurring again. Will let you know how it goes!

#372827

Hello,

In this case I will wait for the results.

Thanks.

#378349

This is fixed. For future reference, we added this to functions.php

Now when the parent post is updated, it does not trigger automatic updates for the child posts.

add_action( 'init' , 'remove_wpcf_pr_admin_save_post_hook' , 10 );
function remove_wpcf_pr_admin_save_post_hook() {
	remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 20, 2 );
}
#458114

Thank you Rachel! I find it useful too.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.