Importing Your WordPress Posts to a Separate Website

This is something I have been trying to figure out how to do for months – and I finally did it!!! So for those of you who are also trying to display your latest blog post (or posts) on a separate website or page of your website – here you go!

First, we will download the SimplePie library. Unzip the downloaded file and upload to your website’s root folder on the server.

The next thing we need to do is create a php page. (For this tutorial, we’re going to assume you are planning to display your most recent blog posts on your website’s index.html page). The easiest way to do this is to rename your index.html page as index.php. However – before you do this – make sure that you are not now going to create a bunch of broken links from visitors coming from other sites and trying to find For this reason, I recommend that you make an exact copy of your index.html page and save it as index.php, upload it to your server, and then add this line of code to the head of your index.html page so that visitors are automatically redirected to the index.php page:

<meta http-equiv="refresh" content="0; URL=">

Change the URL in the code to your index.php file’s URL. (Note: another suggestion I have is that you wait to insert the code to redirect your index.html page until you have the index.php page completely ready to go. This way, visitors won’t see the index.php file as you are working on it, and they won’t get a “Page Not Found” or some other error should things go wrong.)

Next, insert this line of code to the very top of the page where you are trying to display the WordPress posts:

include_once $_SERVER['DOCUMENT_ROOT'] . '/';
$feed = new SimplePie('');

Obviously, you need to make sure that the addresses to your file and to the blog feed that you are trying to import are correct.

Now, we simply need to add the imported blog post or posts to the web page!

To display the 5 most recent blog posts, use this:

<h1><?php print $feed->get_title(); ?></h1>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
        <a href="<?php print $item->get_permalink(); ?>">
        <?php print $item->get_title(); ?></a>
<?php endforeach; ?>

To display the entire most recent post, use this:

<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_content(); ?>

Once you have the blog post or posts imported into your web page, you can go about styling the way it displays. The code that I use to import and display my most recent post on my home page is this:

<font size="3"><a href="">Latest from the Blog</a></font>
<?php $item = $feed->get_item() ?>
<a href="<?php print $item->get_permalink(); ?>">
<font size="3"><?php print $item->get_title(); ?></h3></a></font>
<font size="2"><?php print $item->get_description(); ?></font>

You can see that I use “font size” to make sure that the imported blog title and description fit comfortably into the div that contains them.

I hope this works for you! If it doesn’t or if you have any issues, let me know and I will try to help you out as best as I can. Enjoy!

  • Pingback: WordPress: Displaying your latest blog post on a static page | The Web Design Blog()

  • Ben O Crawford

    How do you change how much of the post is displayed?

  • http://N/A Dave


    I just keep getting several lines of error code. Ideas?


  • Libby Fisher

    Hi Dave,

    Can you please post or email me ( a link to the site you are working on so that I can look at the files?



  • eric

    Thanks so much – very helpful!

  • Stephen

    Thanks for this Libby. It’s working beautifully.

    • Libby Fisher

      Hi Stephen,

      I am glad to hear that, thanks for letting me know! :)

  • Arpan

    By clicking on the home page button I can see your home page. My question is that how did you manage the posts getting change??What is the code behind that?? Thank you.

    • Libby Fisher


      I am sorry but I don’t understand the question. Thanks!

  • Tim

    I’ve been trying to figure out how to do this for a few days now and then found your blog :) but… it is working except I keep getting this “Warning: ./cache is not writeable. Make sure you’ve set the correct relative or absolute path, and that the location is server-writable.” at the top of the page and instead of being centered my page is now shoved to the left. Can you offer some help? thanks

    • Libby Fisher

      Hi Tim,

      That means you should double check the permissions on the folders and files that Simple Pie is using. Please let me know if you need further help.


      • OrSeep

        Hey Libby,

        Please provide more details for “permissions on the folders and files that Simple Pie is using”

        My website is also facing the same issue as Tim said.


        • Libby Fisher

          Hi Edward,

          It looks to me like simply a CSS styling issue – your submenus are too far away from the menus so when you move the cursor right to click on a submenu, it moves off of the menu item and the submenu disappears.

        • Libby Fisher


          Here is an article that may explain the file/folder permissions issue – Please let me know if you have any other questions. Thanks!

  • ayman

    i want recent post from my subdomain website on my website master

    example :

    i use wordpress

    how i make that ?

    like this is


    • thelibzter


      I have never tried to display the most recent posts from a different WordPress site on my site before, but this plugin looks like it might do what you are looking for – I haven’t tried it myself so I have no idea if it works or not but it looks promising :)

  • John

    Hello, followed your instructions. I downloaded the kit and followed their instructions. Added the code to the webpage but it fails at: ‘/’;

    This does not exist. I searched for it in all the installed simplepie folders but it is nowhere to be seen.

    But thanks for trying anyway.


    • thelibzter


      Well did you follow the instructions in the first line of the blog post:

      First, we will download the SimplePie library. Unzip the downloaded file and upload to your website’s root folder on the server.

      If you did that, there should not be a problem with the file “not existing.”

  • Energy Drink Dude

    Ahh. Found your other post, where you import into post into another WP page, and now I see you have done what I had commented about in the other post. Awesome. I wonder if you could use the .htaccess directive that allows you to run php in HTML pages to avoid renaming the index.html page altogether. Hence avoiding any redirects. But your solution would seem to work just as well.

  • Libby Fisher


    I would look into this plugin – I have not used it myself but it looks like it may do what you are looking for.