1

So weird, huh? But, not joke --> I try to be very clean of being: I have a subdomain based multisite network. If the users posts to their sites, I get a clone from the current post to my network home.

Now I want get the clone post's id on the subsite with switch_to_blog(); from the network home. How to get this clone post, if users not always using titles -> so no always titles and slugs... The original post's ID's are not the same with the clone ID's...

I think the last and sure chance is if I get the post ID by the $content:

 $original_author = get_the_author_meta( 'ID' );
 $content = apply_filters('the_content', $post->post_content);
 switch_to_blog( 1 ); 
 $args = array(
   'author' =>  $original_author,
   'post_type'   => 'post',
   'post_status' => 'publish',
   'numberposts' => 1,
   'post_content' => $content // unforunetly not working :/
 );
 $my_posts = get_posts($args);
 if( $my_posts ) :
 $exit = $my_posts[0]->ID; //this will the clone's ID
 endif;
 restore_current_blog();

Somebody have any idea?

  • 1
    And how are the post copied to the main site? Why don’t you create a relation while copying them? It would be much easier, I guess... – Krzysiek Dróżdż Jun 6 '18 at 7:57
  • 1
    this is interesting, I use the WDS Multisite Aggregate, and when an original post's content updated, also updated the clone post, so I think, here is sure a relation... Now I am reading in the subject, thanks your reply! – Galgóczi Levente Jun 6 '18 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.