php-scripts.com integrating phpblog within non-Wordpress page screenshot

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:

<?php
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(’, ‘) ?> &nbsp;</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: ,