Here’s a quick and simple trick to integrate WordPress into a static website. If you’re like me prefers to build out a static website that has dynamic capabilities to extend upon then this tweak will be your new best friend and save you literally hours and hours of coding time. Any WordPress plugin that uses shortcodes will work within a static PHP webpage.
Insert the following code at the very first line of a static php page.
<?php require('blog/wp-blog-header.php'); status_header( 200 ); define('WP_USE_THEMES', false);?>
Be sure to update the filepath to WordPress. The wp-blog-header.php file sets up all of the variables required by the WordPress environment allowing you to call WordPress elements and plugin shortcodes in a non-wordpress page. There’s dozens of usages such as login forms, multistep contact forms, galleries and many other usages.
I use the technique here on Sitebee to embed contact forms within static non-wordpress page. All that is needed is to call the element or shortcode like this.
<?php echo do_shortcode( '[ffb id=1]' ); ?>
Thats it, so simple with lots of scope to extend the functionalities of a static php page. All that is needed from you is the replace [ffb id=1] with your shortcode ID. I’ve mastered the technique so if you need any help, get in touch. My standard hourly rate applies.