We’ve recently done some extremely tight integration with our billing system (WHMCS) and our main site (WordPress).
As things developed, we found ourselves needing more than just copying and pasting HTML could offer. Widgets generated dynamically for example, had to be updated without us having to manually copy the new markup over every time something changed.
Luckily, it was a lot easier than we expected to bring the entire core of WordPress into our WHMCS instance.
Not only are we pulling headers and footer from WordPress, we’re pulling pages and content blocks (see our blocks plugin). This allows us to edit parts of our WHMCS pages using our WordPress page builder, and everything is updated automatically.
It’s actually very simple to set up. This can be used outside of WHMCS of course, but the code here is for Smarty, the template engine used by WHMCS.
The following edits are made in WHMCS template files, such as “templates/default/header.tpl”. Change “default” to whatever the name of the custom template you are working on is.
First step is to bring in the WordPress core.
{php} define('WP_USE_THEMES', FALSE); require('/path/to/wordpress/wp-load.php'); {/php}
You can do this at any point on the page. We do it in header.tpl, so that WP functions are available throughout the rest of the page.
Next, call whatever WordPress functions you’d like to.
{php} get_header(); {/php} {php} get_footer(); {/php} {php} include(get_template_directory() . '/file.php'); {/php}
You can pretty much do anything here that you would do in your WordPress templates.