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?
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.
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.
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.
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!
Hello,
In this case I will wait for the results.
Thanks.
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 );
}
Thank you Rachel! I find it useful too.