Use WordPress functions in a static site

Sometimes, you may want a landing page that’s entirely different from your WordPress site, perhaps for a business. But, you want to advertise your blog as well on your site, with more engaging content than a link that points a user to your blog. Wouldn’t it be nice if you could list your most recent blog posts, or maybe even a snippet of your last post?

You can. And it’s really simple.

All you have to do is insert the following code above your <head> tag:

define('WP_USE_THEMES', false);
require('/path/to/wp-blog-header.php'); //ex: /var/www/wordpress/htdocs/wp-blog-header.php

Once inserted, you can use any of the WordPress functions in your template that you want, wherever you want.

Wasn’t that easy?


Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>