Saving parent post copies all post meta to child posts
I have two custom post types (let’s call them Parent & Child). Posts of type “Parent” can be set as the parent of posts of type Child.
I create two posts of each type (let’s say parent_post & child_post) and set parent_post to be the parent of child_post using “Child belongs to” option on the edit screen of child_post.
Now, whenever I go back and edit the parent_post all of its meta_key / meta_value records are copied to child_post in the database.
I use other plugins like ACF & SEO by Yoast. Taking SEO by Yoast as an example, whenever I change the SEO values of parent_post they are saved as meta key/values. Types then copies these values to child_post, thereby overwriting any SEO data it already had.
For example, if I change the SEO Page Title of parent_post then that gets copied to child_post and overwrites it’s SEO Page Title.
I’ve tested this on a fresh install of WordPress with just Types & SEO by Yoast installed. The same thing happens. All the parent_post meta values are copied to the child_post every time parent_post is saved.
To compound matters, this propagates if you have multiple levels of parent/child relationships defined. This causes huge bloat in the postmeta db table and causes child_post data to be lost.
- The topic ‘Saving parent post copies all post meta to child posts’ is closed to new replies.