HowTo – Including WordPress Function On Outside Pages

Filed under: Wordpress Tips

wordpress-logoThere are times when you need to make use of special scripts or content generation methods that are not conducive to WordPress but you also don’t want to lose access to the parts of your site that WordPress Generates.

This could be the situation if you had a dedicated payment shopping cart system or if you had a inventory database that is not easily imported into WordPress.

To begin using WordPress functionality on outside pages you must begin by adding the WordPress Header to your pages.

/* Include The WP-Header */
define(‘WP_USE_THEMES’, false);

Once you have read the header into your php pages you can do just about anything…

For instance adding a list of links of your latest 5 posts to your outside pages you would use.


<?php // get the header

<?php query_posts(‘showposts=5’); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
<?php endwhile;?>


More complex options are available but may require a significant amount of debuging to make sure correct directory structures are preserved.