WordPress前端发布到具有高级自定义字段的多站点中的多个博客


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

我正在使用高级自定义字段叶端发布。

<?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' );
?>

我想使用此方法

<?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
?>

如何同时发布到多个博客。 请帮助我。

问题解决了!.我从这里得到了一个解决方案。http://support.advancedcustomfields.com/forums/topic/front-end-posting-to-multiple-blog/