Hello friends I am trying to get my wordpress posts to display in a non- wordpress application. Currently I am getting them by using the following method.

My wordPress page is something like this:

<div id="header">
    <!-- header content goes here -->

<div id="main-body">

    <div id="content">
        <!-- Main Body goes here -->

    <div id="sidebar">
        <!-- My Sidebar Widgets go here -->

<div id="footer"
    <!-- My footer goes here -->

and I am using:

<?php file_get_contents('http://mysite.com/blog'); ?>

It's working ok but there are 2 issues.........

  1. It is getting the entire page.

  2. My page stops loading till it fetches the wordpress data.

Hence I thought AJAX was the solution. But I don't know AJAX. hence decided to seek help here.

What I am looking for is that I just want the output content of #Content Div and #sidebar Div separately so that I can place them in my other application in two different places.

I don't even need the CSS or JS as they are common for both my themes. I just want the output and separately placed at 2 different place.

Please help.

  • You could do a JSON request using MooTools(you mentioned using it in one of your comments).. mootools.net/docs/core/Request/Request.JSON ... not used Moo Tools myself, but the page linked provides a simple enough example(let me know if it helps). – t31os Jan 4 '11 at 16:49

If it is all on same server it is rather easy to load WP engine and parts you need, see Integrating WordPress with Your Website.

Otherwise there is probably better to get specific data (rather than whole page) from WordPress remotely, but there are a lot of approaches to that. Also I am not aware of any off-the-shelf code that allows to do that for sidebars. For post content there is XML-RPC support and plugins for other formats (I think I read about JSON one).


If you're using jQuery, you can request part of a page. Here's an example using this technique.

  • Actually I am using MooTools in my other application an I dont want to load another library like jQuery just for this purpose as it will make my application heavy – Vikram Dec 31 '10 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.