0

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

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

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

4

1 回答 1

0

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

于 2013-11-14T09:07:22.533 回答