wordpress integration (article one)
So I am well aware I posted a while ago that I would be doing up some articles discussion wordpress & site integration. I have been very busy with some other things but I finally got around to writing this out. So before we being I would like to kind of give you and over view, in my mind, as to how this articel and the ones to follow will play out.
First up in this article I will go on to talk about how to use wordpress and its pluings (well there functions anyway) on a a simple regular old page. I think think this is one of the most simple, yet, overlooked things that wordpress allows users to be seamlessly. For this example I am going to be dissecting my site (binslashbash.org) the site you are currently at, well I hope anyways, or someone has stolen this article without my permission… Anyways back on track, after this article the next installment will be about creating a theme that flows, and using the same look throughout the rest of your site. From thee I will get into more of writing custom plugins to do things you want etc… etc…
So let’s get down to business. First up was how to integrate wordpress into a static page that really has nothing to do with your blog. I know this may sound like a donting task, however it’s simple, in fact so simple its only really one line of code:
<?php require(’./wp-blog-header.php’); ?>
Yes that’s it. Please keep in mind that that path will be reletive to where your page is. For example I like to install wordpress right into my /home/jnewing/www/ directory so for my other pages such as about.php and so on I can use the exact code above, however if I was to have a page in a directory like: /home/jnewing/www/mydir/ then I would have to change the above to look more like:
<?php require(’../wp-blog-header.php’); ?>
or
<?php require(’/home/jnewing/www/wp-blog-header.php’); ?> (if you prefer absolute paths)
Ok so now your ready to being calling wordpress functions. It was just that easy. A good example of this is my blogs mullet (tag cloud) you’ll notice that this appears on all of my pages, index.php, about.php, contact.php and so on. This is done by simply calling the function that the plugin uses.
Example:
<h3><img src=”http://binslashbash.org/images/tagcloud.gif” alt=”tag cloud” /></h3>
<div class=”content”>
<p><php? UTW_ShowWeightedTagSetAlphabetical(”coloredsizedtagcloud”,”",0); ?></p>
</div>
As I stated you’ll find that code throughout my website, even tho not all pages are a “part” of wordpress. I have done some semi integration by simply adding the “wp-blog-header.php” file to my created website.
Well that is all I am going to talk about in this first article but I will continue them, and hopefully build a nice little series of them. I was also considering throwing Smarty into the mix since I love it so much. I think it’s one of, if not the, best template engine going. Anyways be sure to leave me some feedback as to what you would like to see, and what you thought about this.












Hi, thanks for the very interesting article!
I know I am a real wordpress cabbage and don’t know any PHP, but things that I need to know are like how to keep navigation dynamic so it knows which page you’re on (like currently you have weblog highlighted - and ideally I would like to remove the link from that item when someone is in a section), and how to call the post names, etc.
Maybe this is too basic for you to post here, but do you know of any tutorials you could point me to? When I search Google, I get a lot of developer tutorials but not any help for the more basic stuff.
*thanks!* Rachie :)
Hi Joseph,
Really enjoying looking at your design, it works very well, and a good example you choose to start of your wp-integration series.
Curious to see what’s next !
Best, Daddo