Requirements
- Maintain the hierarchy of content in the target site
- Set the correct value for post_parent
- Set the correct value for featured image
Solution
- Client determines the target post parent for the server
- It passes the mapping to the server
- The server checks the validity of the given mapping, to ensure that we don’t create a post with the wrong parent. Otherwise we might end up with the post being created as a revision of the wrong post altogether.
- If OK, then the post_parent is set, otherwise the parent is set to 0
Limitations
- Only tested with “published” posts
- After a post parent has been (re)set to 0 rather than the requested target, it will be necessary to perform a second update, when the remainder of the post’s ancestry has been cloned