multisite - Shared Custom post type between WP network sites

I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are W

I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are WP, and I've got them in a Network. I would like Events to show up in all three Admin interfaces with the same data. All being able to create and edit. Is it possible? It's all the same DB..

I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are WP, and I've got them in a Network. I would like Events to show up in all three Admin interfaces with the same data. All being able to create and edit. Is it possible? It's all the same DB..

Share Improve this question asked Feb 12, 2015 at 17:52 Jon RamviJon Ramvi 1014 bronze badges 1
  • 1 It is possible, butnl not only with the default. The database is the same, the tables are different on default. Each post type is in each blog and his post table. You must create helper functions on create, save post hook to copy to the other blog. But I you like always the same data, then is a other way better, that you not have redundant data. I give it not the way A answer, it is depending from a lot of points. – bueltge Commented Feb 12, 2015 at 20:33
Add a comment  | 

2 Answers 2

Reset to default 0

It doesn't seem to be a WP Network main object for getting data from other sites in the Network i.e. $wp_network->site1->get_post_type('events'). I solved this using the automatically generated RSS feed for the custom post type. The feed is available on /[custom post slug]/feed

How to read the data from other WP sites

WP comes with SimplePie for easy RSS operation.

$rss = fetch_feed('http://exmaple/[custom post slug]/feed');
$rss_items = $rss->get_items(0, 10);
foreach ($rss_items as $item) : ?>
    <h4><?php echo esc_html($item->get_title()) ?></h4>
<?php endforeach; ?>

An alternative solution is to use WP REST API: http://wp-api/

If your custom post type uses custom fields, the RESP API saves you the trouble of including the custom fields in the RSS.

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

相关推荐

  • multisite - Shared Custom post type between WP network sites

    I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are W

    11小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信