Find Site ID From WP_Post

Question

Background

I am writing a migration tool that can move (copy, then delete) posts from one site on a multi-site network to another. I want to correctly separate concerns, and from that point of view it seems that in order to migrate a post from one site to another you need to things:

  1. The post – in WP represented by a WP_Post object.
  2. The site ID – ID of the site to migrate it to.

Question

How can I, being given only a WP_Post instance, get the ID of the site it belongs to?

Remarks

Foreseeing answers that just use get_current_blog_id(): that will get the ID of the current site, whatever that is. I want the ID of the site that the given post belongs to.

0
XedinUnknown 4 months 0 Answers 14 views 0

Leave an answer