At times you might want to run the WordPress queries or wordpress functions in the page located outside the wordpress templates.
Thanks to wordpress for providing a very simple solution to this.
You just need to include the file called “wp-load.php” in the non-wordpress file before calling any WP functions and then you can run wordpress queries or call any wordpress function in that page.
wp-load.php is located in the root folder of your wordpress installation.
eg. if you have installed wordpress in your domains root folder, wp-load.php will be there in your public_html or httpdocs folder as applicable.
if you have installed wordpress in a folder say wp in your domain root, the wp-load.php shall be located in public_html/wp/ folder.
Include this file in your non-wordpress file using a require statement at the very beginning of the file.