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.