get post id by $content (so by post content)
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?
Topic switch switch-to-blog subdomains the-content multisite Wordpress
Category Web