tip-of-the-dayIf you have a WordPress blog and vBulletin forums, you might be interested in how to integrate your vBulletin forums into your WordPress theme so you can get a consistent look and feel across your website. I came across this article by Depressed Programmer from 2009, which still works with the current version of WordPress and at least vBulletin 3.8.x. I’m not sure about vBulletin 4.x.

Note: This works better with some themes than it does with others, so if you run into issues, you might want to consider a different WordPress theme, otherwise you might have to do some CSS tweaking.

Enable The Plugins/Hooks System

First you need to have this enabled (which it usually is already). Go to vBulletin Options under the vBulletin Options from the admin control panel. Select the Plugin/Hook System option in the select list and make sure its enabled.

Create Two Plugins

Click on the Add New Plugin option under the Plugins & Products on the left hand side of the control panel. Create a plugin with the Hook Location specified as global_start and the default execution order. Give it the title of WP Header and in the Plugin PHP Code field, write the following:

ob_start();
include('../path/to/wp-load.php');
include('../blog/wp-content/themes/sandbox/header.php');
$wp_header = ob_get_contents();
ob_end_clean();

Remember to select the Yes radio button to make the plugin active and click Save.

Next, we’ll do the footer plugin. Specify the Hook Location as global_start, give it the title of WP Footer and select the default execution order. In the Plugin PHP Code field write the following:

ob_start();
include('../blog/wp-content/themes/sandbox/footer.php');
$wp_footer = ob_get_contents();
ob_end_clean();

Again, click Yes to make it active and Save.

Reminder: Be sure you change the path locations in the include lines to match your WordPress theme!

Template Edits

Now we need to edit two templates, the header and footer, and call our plugins.

Go to Style Manager under the Styles & Templates group in the left control panel. Once there, select Edit Templates from the drop down list which should give you a listing of all the editable files in your theme. Double-click on header from the list and simply add the following line of code as the first line in the file:

$wp_header

Save it and go back to the list of editable files and edit footer. Make sure the following line of code is the last line in the file:

$wp_footer

Save this template.

Depending on the version of vBulletin you have you might get a PHP error which says something like “sanitize_url function has already been defined”. Check the vBulletin file its happening in, download it and rename both occurrences of the function to something like vb_sanitize_url and now you’re done.