最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multisite - Shared Custom post type between WP network sites

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论