How might I retrieve a featured post image from an external WP site and display it as a link back?

Whenever I’m trying to link two sites, I find the most efficient and least destructive way is to use the WordPress XMLRPC API. http://codex.wordpress.org/XML-RPC_WordPress_API/Posts

In this case, you could pull this info through using the built in IXR_Client library. This saves a ton of time writing code and trying to mix databases. If they wind up on completely different servers at some point. You can still have this work.

It’s pretty much just this…

$client = new IXR_Client(XMLRPC_URL);
$client->timeout = 1;
$USER = XMLRPC_USER;
$PASS = XMLRPC_PASS;
$req = 'wp.getPost';
$post_id = 112;
if (!$client->query( $req, $post_id, $USER, $PASS ))
{
    die( 'Error while creating a new post' . $client->getErrorCode() ." : ". $client->getErrorMessage());
}
$postcontent =  $client->getResponse();

Leave a Comment