我正在使用高级自定义字段前端发布。
<?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
?>
如何同时发布到多个博客。请帮帮我。
答案 0 :(得分:0)