So i was asked the other day about my installation of wordpress on my cash advance site, specifically how I went about getting a recent post list out of wordpress and onto the home page, when the home page of the site is not inside of wordpress.
Some quick background, my cash advance site (http://www.mycashdirect.com) is a combination of the Zend framework and WP. The only portions of the site being run via WP is only /loan-articles/.
Back to the question… Simple answer and i’m sure there are other ways of doing this, but it worked… Proxy via ajax or curl, your choice.
Mine happens to be curl because the function started out as something else and I was to lazy to switch it to ajax, which would be better and I’ll have to do that later…. any who
My Zend function that is called on the home page via a view:
class Library_View_Helper_RecentArticles
{
public $html = '';
public function recentArticles($limit=3)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.mycashdirect.com/loan-articles/article-proxy/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$this->html = curl_exec($curl);
curl_close($curl);
echo $this->html;
}
}
Pretty simple, yes it needs to be ajax…. I know…
On the Wordpress side, I create a page called proxy, and assign a template to that page called… proxy
that template looks contains a custom loop that only grabs the most recent three post and pushes it out to the page. You can actually see that page directly if you go here.
And that is about it, I get to use the native functionality of WP outside of WP. Sure, I could have written the homepage inside of WP, but that would have been to easy.