Code Snippet To Add and Use Own PHP File in WordPress In Plugins or Themes

First published 6 May 2015

This article is from our archive. It is kept as it was first written, so some steps or versions may be out of date.

If you want to use own php file in WordPress, you need to make the file friendly to WordPress so that I can read rest of the core WordPress funtctions. Add this snippet on the top of the php page you create.
PHP code: define('WP_USE_THEMES', false); followed by require('../wp-blog-header.php');