Display Wordpress content from Outside Wordpress
Posted: December, 29 2007Ever wanted to call Wordpress functions from outside the Wordpress installation?, no plugin required, just a few lines of code.
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.
- Firstly create a new file called: newest.php and place it in the WordPress root folder, here is the code for newest.php:
<?php $limit=5; $more=1; $count=1; if (empty($wp)) {require_once('wp-config.php'); wp('feed=rss');} if ($posts) { foreach ($posts as $post) { start_wp(); ?> <ol> <li> <div class="small"> <?php the_time('l, F jS, Y') ?></div> <?php the_excerpt() ?> </li> </ul> <?php $count++; if ($count > $limit) { break; } } } ?> -
Use the following code outside Wordpress, in a static Index page, sidebar, header - simply wherever you want the Wordpress content to be shown:
<? @include ($_SERVER['DOCUMENT_ROOT'].'/wordpress/newest.php'); ?> - Sorry, no more steps, that’s it your done!
- 08.08.07: Stunning new Photo tool to fix bad images (2)
- 30.11.07: Stirrdup - Simple, Fast and better than Digg (0)
- 28.12.07: No more Netscape for 2008 (0)
- 12.01.08: Google Pagerank update January 2008 (11)
- 16.01.08: Firefox Popup not resizing (0)
That will list the latest post titles (default 5), display Date of Post, and an excerpt of the post.




thx for this little tutorial! One digg from me
Go to Top of the page