Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggreagtion Enquires Welcome

WordPress Features on a non-WP Page

The following code will allow you to create your own random pages while utilizing the full features of your WordPress installation. All you'll have to do is copy the following code into a blank file with a PHP extension. You'll have to be careful to ensure you correctly reference the wp-load.php WP file.

1
<?php 
2
require( '../wp-load.php' );
3
4
echo 'This is content outside of WordPress';
5

This code will display the WP header, footer and the text, "This is content outside of WordPress". If you wanted to include basic HTML in your page without the PHP entanglements, you could use:

1
<?php 
2
require( '../wp-load.php' );
3

This is content outside of WordPress

1
<?php 
2
get_footer();

If you choose to use shortcodes in your non-WordPress page, you'll have to use the following (remembering you're outside the loop).

1
<?php 
2
$content = "Content outside WordPress [MyShortCode]";
3
echo do_shortcode($content);

You can add widgets and other features... and use any other components of WP as required. However, in most cases, the feature isn't much different to a blank WP page.

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment