multisite - How to share same post to multiple site in wordpress?

We are developing WordPress with multiple site. We need to share some posts to more than one site. We need to save post

We are developing WordPress with multiple site. We need to share some posts to more than one site. We need to save post in more than one sites with a single click.

I have searched in Google, but I can't get any tutorial for that.

We are developing WordPress with multiple site. We need to share some posts to more than one site. We need to save post in more than one sites with a single click.

I have searched in Google, but I can't get any tutorial for that.

Share Improve this question edited Jul 13, 2016 at 19:00 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Jul 13, 2016 at 18:35 muthupandimuthupandi 211 gold badge1 silver badge2 bronze badges 3
  • A bit off-topic but wouldn't that be considered as duplicate content and bad for SEO? – Sledge Hammer Commented Jul 13, 2016 at 18:40
  • 2 @SledgeHammer No that's syndicated content an not necessarily bad for SEO – cjbj Commented Jul 13, 2016 at 18:49
  • "Multiple site" doesn't mean a multisite network, right? For anyone who is still looking for a similar solution, I'd recommend to check this plugin out rudrastyh/plugins/simple-wordpress-crossposting – Misha Rudrastyh Commented Jun 1, 2024 at 11:07
Add a comment  | 

2 Answers 2

Reset to default 2

You can use the function switch_to_blog() for this

$other_id = 1234 // the id of the other blog to save the post to
switch_to_blog($other_id);
$my_post = array(
  'post_title'    => $post_title,
  'post_content'  => $post_content,
  'post_status'   => 'publish',
  'post_author'   => $post_author,
  );

// Insert the post into the database
wp_insert_post( $my_post );

restore_current_blog();

There is a pitfall if you execute this code on the save_post hook, because wp_insert_post also calls save_post and you end up in an infinite loop. This post on Stack Overflow gives a solution for that.

Author of Broadcast here.

Seeing as I have quite a bit of experience with multiposting, and all it's associated problems, I'd suggest you let an experienced plugin take care of post sharing.

Using the API you can broadcast out the post to however many networked blogs you want. It will take care of all of the copying of attachments (yeah, attachments have different URLs and IDs on each blog) for you.

Here's how to broadcast post 123 to several blogs:

ThreeWP_Broadcast()->api()->broadcast_children( 123, [ 10, 11, 12 ] );

The above will also link the posts together, so when you update post 123, all of the children will be updated also.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745141275a4613442.html

相关推荐

  • multisite - How to share same post to multiple site in wordpress?

    We are developing WordPress with multiple site. We need to share some posts to more than one site. We need to save post

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信