It was only a few minutes after posting a link to this page that I received a question on how it was done. It may not look like anything special, and it isn’t, but the whole page was rendered with just a few lines of code. Basically, I’m using the WordPress header and footer, and all the features of the core, outside of traditional WordPress pages.
This code will allow you to create your own random pages while utilising 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.
<?php require( '../wp-load.php' ); get_header(); echo 'This is content outside of WordPress'; get_footer(); ?>
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 entaglements, you could use:
<?php require( '../wp-load.php' ); get_header(); ?> This is content outside of WordPress <?php get_footer(); ?>
In the case of the page I linked to, I use shortcode to dump the contents of a directory onto a screen. I use [listcontents="jplayer" directory="jplayer"]. I’ll provide this code another time.
If you choose to use shortcodes in your non-WordPress page, you’ll have to use the following (remembering that you’re well outside the loop!).
$content = "Content outside WordPress [MyShortCode]"; echo do_shortcode($content);
I hope it was useful.
Note: I’m still undertaking a course that’s consuming a lot of my time… thus the infrequent posts. Thanks for the emails!
|
|
If you liked this article, you may also like:
- Create a Genesis Page Outside of WordPress
- [Shortcode] Easily post an aviation TAF report into your WordPress post or page with shortcode
- Prevent WordPress Pages from appearing in Search Results
- [Shortcode] Easily post an aviation Metar report into your post or page with shortcode
- [Shortcode] Include an RSS feed in a post or page with shortcode


I am using this function in index page outside from wordpress. But It will redirect it to wp-admin/install.php.
Kindly suggest me some solution for this.