Load custom post type in a different WordPress installation

The simplest way to get post from WordPress to WordPress is to use RSS. You can use SimplePie to work with the feeds on your destination site. http://simplepie.org/wiki/reference/start

I used this technique to get posts from WordPress to Joomla CMS and I never looked back.

Edit Added

I have used feeds for this in the past and it works very well, and SimplePie is comes with WordPress, you just have to add the proper class. I used this method to get the latest posts into a Joomla site and it worked flawlessly.

To get to your feed URL in code checkout get_category_feed_link or the_category_rss() (Note: the_category_rss() must be in the loop)

This is how you get a feed from anywhere into WordPress
You might want to break it down to use filters and actions but this is the basic idea and will work just fine if you just drop the files into your template file.

Includes

<?php 
require_once  (ABSPATH . WPINC . '/class-feed.php');

$feed_url="feed://techcrunch.com/feed/";
$feed = new SimplePie($feed_url);

?>

Display code

<h1>Latest 5 Post<?php print $feed->get_title(); ?></h1>
<ul>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
    <li>
        <a href="https://wordpress.stackexchange.com/questions/38551/<?php print $item->get_permalink(); ?>">
        <?php print $item->get_title(); ?></a>
    </li>
<?php endforeach; ?>
</ul>

<h1>Latest post from <?php print $feed->get_title(); ?></h1>
<?php $item = $feed->get_item() ?>
<h2><?php print $item->get_title(); ?></h2>
<?php print $item->get_description(); ?>

Command for getting feed URL from source WordPress site ( runs anywhere )

$url = get_category_feed_link('25', ''); // get your category id
$feed = SimplePie($url);

Possibly helpful links

Simple Pie Sample Page : http://simplepie.org/wiki/setup/sample_page

WordPress get_category_feed_link() : http://codex.wordpress.org/Function_Reference/get_category_feed_link

Some nice SimplePie code samples you can start with: http://www.corvidworks.com/articles/easy-feed-reading-with-simplepie

Leave a Comment