How do you get the docroot directory?

// server document directory $dir = $_SERVER[‘DOCUMENT_ROOT’]; // wordpress install directory $dir = ABSPATH; to include safely with wordpress add_action(‘plugins_loaded’, ‘load_a_file’); function load_a_file(){ if( is_admin() ){ $dir = $_SERVER[‘DOCUMENT_ROOT’]; include_once( $dir . ‘/file.php’ ); } }

Debug Performance Issues

There are essentially two very different cases how WP site typically bring server down with symptoms of CPU overload: Your site is not fast enough for your traffic Simply put if your server can serve page every tenth of a second and you get more than 10 pageviews in that second – your resources are … Read more

CPT Template Not Showing – Getting 404

Always flush the rewrite rules when you register a new public post type or taxonomy. Otherwise the internal rewrite rules will not take that into account when an URL is mapped to a query. You can automate that process by hooking into registered_post_type and registered_taxonomy. Below is the updated code, based on feedback from comments … Read more