WordPress front end posting to multiple blog in multisite with advanced custom field

I am using advanced custom field frond end posting.

<?php 

function my_pre_save_post( $post_id )
{
    // check if this is to be a new post
    if( $post_id != 'new' )
    {
        return $post_id;
    }

    // Create a new post
    $post = array(
        'post_status'  => 'draft' ,
        'post_title'  => 'A title, maybe a $_POST variable' ,
        'post_type'  => 'post' ,
    );  

    // insert the post
    $post_id = wp_insert_post( $post ); 

    // update $_POST['return']
    $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    

    // return the new ID
    return $post_id;
}

add_filter('acf/pre_save_post' , 'my_pre_save_post' );

?>

I want to use this method

Read More
<?php
$original_blog_id = get_current_blog_id(); // get current blog

$bids = array(1,2); // all the blog_id's to loop through
foreach($bids as $bid):
       switch_to_blog($bid); //switched to blog with blog_id $bid
       // ... your code for each blog ...
endforeach ; 

switch_to_blog( $original_blog_id ); //switched back to current blog
?>

How can I Post to multiple blog at same time. please help me.

Related posts

1 comment

Comments are closed.