
Wordpress makes it easy to create a loop of recent posts to put on other PHP-enabled, non-Wordpress pages. For example, on the home page of this website (pictured above), I wanted to include the most recent post titles and related category links from this new blog. As new posts are added, they will flow to the top and the old will push to the bottom and then off the page. Also, I wanted to have the date/time to show site visitors how often new content is being added (I was becoming pretty tardy with my diary entries). To do what’s shown in the screenshot above with the red arrows pointing I used the following PHP code:
require(‘./wp-blog-header.php’); // alter to path to wp-blog-header.php script on your site
?>
<!– if you want to have a title graphic it goes here –>
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
# <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a> <small> in <?php the_category(’, ‘) ?> </small><small><?php the_time(’m-d-Y’); ?> <?php the_time(’g:i a’); ?></small><br />
<?php endforeach; else: ?>
<!– put what you want here when there are no posts –>
<?php endif; ?>
Copy and paste that and easily add your recent posts to your non-Wordpress page, slick!
tags: Wordpress, blog integration

[…] Here’s the skinny: PHP-Scripts Blog ยป Showing most recent blog posts on non-Wordpress pages Wordpress makes it easy to create a loop of recent posts to put on other PHP-enabled, non-Wordpress pages. […]
on September 7th, 2005 at 11:00 am | #Link Comment[…] wie man Blogartikel irgendwo auf einer anderen PHP Webseite anzeigen kann. | Permalink | Trackback-URL […]
on September 11th, 2005 at 10:43 am | #Link Commentthis one works perfectly. + easy to insert in non-wp-pages. big up!
on October 6th, 2006 at 5:16 am | #Link Comment[…] on the homepage and some other pages to match the design of the blog. I’m thinking this mini-tutorial might come in […]
on September 27th, 2007 at 7:26 pm | #Link Comment