voodish logo
tweet rss book of faces Linked In

Display Wordpress content from Outside Wordpress

Ever wanted to call Wordpress functions from outside the Wordpress installation?, no plugin required, just a few lines of code.

Please note, this is an old article suitable for WP1/2, a new version is being built. In the meantime look at replacing wp-config.php with wp-load.php for WP 2.5 onwards.

 

Using this snippet you can list post titles, even excerpts or comments outside of Wordpress on your website without having to go through the web interface.

It’s as simple as creating a new PHP file. ie. newest.php in your Wordpress root (topmost folder) and then including it in any other file on your website that is outside of Wordpress.

Comments RSS Feed

2 Trackbacks/Pingbacks

  1. Pingback: WordPress Plugins and Tips - optimize your WordPress Blog on February 18, 2008
  2. Pingback: Show contents of a blog in another Blog - Ultimate Coders Wordpress Developer on July 13, 2013

18 Comments

  1. manele January 6, 2008

    thx for this little tutorial! One digg from me :)

  2. Go to Top of the page

  3. mccormicky September 12, 2008

    I Digg,too! Dugg? Thanks for this!

  4. Go to Top of the page

  5. Synergy Informatics October 3, 2008

    simple yet mighty,

    Thanks for this…

  6. Go to Top of the page

  7. Alexdaklak October 17, 2008

    Can I get to another website?

  8. Go to Top of the page

  9. admin October 17, 2008

    @Alexdaklak
    You would have to have access to the aforementioned files on the other website.

    However you could just hook up into their RSS feed, like so:

    [script type=”text/javascript” src=”http://www.google.com/reader/ui/
    publisher-en.js”][/script]
    [script type=”text/javascript” src=”http://www.google.com/reader/public/javascript/feed/http://www.voodish.co.uk/articles/v-feed.php?n=9&callback=GRC_p(%7Bc%3A’-'%2Ct%3A”%2Cs
    %3A’false’%7D)%3Bnew%20GRC&hl=en”][/script]

    please note you should replace [ ] with <> respectively.
    Hope this helps

  10. Go to Top of the page

  11. Joy November 5, 2008

    This looks good {except for the specifics of calling wp()}, but when I try it on a clean 2.6.3 I get a fatal error inside wp-settings.php that a member function is being called on a non-object. It’s talking about the $wpdb object calling set_prefix. I can’t see why there would be a problem since WP works in every other way. Two lines up it checks !empty($wpdb->error without complaint.
    What am I missing?

  12. Go to Top of the page

  13. Joy November 11, 2008

    I finally got back to trying this out. Here’s’ the error I get:

    Strict Notice: Assigning the return value of new by reference is deprecated in wp-settings.php on line 472

    My server says it has a PHP version of 4.4.8, but I thought it was higher since I’m able to run Magento. (Oh yeah, there’s this in the .htaccess file: AddHandler application/x-httpd-php5 php).

    So is it just my version of PHP that has gone beyond allowing what WordPress is doing (assigning the return value of new by reference)? I guess I can hack the WP settings file not to do it that way…or turn off Strict… maybe?

  14. Go to Top of the page

  15. Marty March 5, 2009

    So is it possible to pull latest posts from different categories on to different pages of a “traditional” separate website using this technique?
    i.e posts in “news” category to a news page
    and post from “offers” category to an offers page.

  16. Go to Top of the page

  17. Alex August 5, 2009

    Is it possible to display comment form and comments from a specific post on a page outside of wordpress? I would like to show post comments on a page that is linked to inside the post but the link is on a page outside of wordpress. Would like to give option of commenting/reading comments in wp and on linked page.

  18. Go to Top of the page

  19. Martino November 3, 2009

    This looks good :)
    Martino

  20. Go to Top of the page

  21. Mark February 20, 2010

    Problem: the_excerpt() doesn’t seem to work with posts that have permalinks. This is indicated in the wordpress codex, and sure enough, I can’t get it to work. Bummer

  22. Go to Top of the page

  23. PACKER April 15, 2010

    In regards to your answer to Alexdaklak’s question: what is “have access” imply? For instance I have several sites hosted together including one with WP and another I’d like to include some of that WP content on using this method. Is there an additional step to load the necessary files or something in the server settings that has to be manipulated?

    Thanks, much. I just much prefer the customization options of a regular include then running it through RSS…

  24. Go to Top of the page

  25. Jared June 18, 2010

    I have tried both of your methods but neither one of them worked :( Is it still valid with the WP3.0 update?

  26. Go to Top of the page

  27. admin June 18, 2010

    ***This is an old article; when I have more time I will build a new version for later WP versions.

    In the meantime, try swapping wp-config.php for wp-load.php, which was new for WP2.5 onwards.

  28. Go to Top of the page

  29. Zahin Wadud August 23, 2011

    AweSome !!!

  30. Go to Top of the page

  31. Anup October 12, 2011

    i have used newest.php and it displayed the content but what i want more is need to add pagination to navigate older content. can anyone help me to do that? i tried but i am not able to do that.
    Thanks in advance

  32. Go to Top of the page

  33. Empresas January 11, 2012

    Thanks

  34. Go to Top of the page

  35. smita February 24, 2012

    when i tried this code for for one blog it’s work great but in multiple blog this code is giving same output as 1st blog.
    why this happen

  36. Go to Top of the page

Leave a comment