admin管理员组文章数量:1414614
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
2 Answers
Reset to default 0It 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.
本文标签: multisiteShared Custom post type between WP network sites
版权声明:本文标题:multisite - Shared Custom post type between WP network sites 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745179678a2646409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论