php - How to include the wp-config file from a folder deeper in the site tree -


i don't know why have trouble including php files. in case i'm trying include wp-config file can use of variables defined in it. file setup.php @ level seen below

wp-admin wp-content    .    .    themes        .        .        mytheme            .            .            setup.php            .        .    . wp-includes . . wp-config.php . . 

and file begins

<?php error_reporting(-1); ini_set('display_errors', 'on');  include '../../wp-config.php';  $con = mysqli_connect(db_host, db_user, db_password);  

and error i'm getting is

warning: include(../../wp-config.php): failed open stream: no such file or directory

i tried doing

include_once get_home_path() . 'wp-config.php'; 

but get_home_path() undefined, means in order use i'd have include file in defined, circular problem because, thread shows, don't know how pull in files @ different levels.

any in solving this?

if developing theme, shouldn't need manually include wp_config.php, wordpress handle you. furthermore, strongly recommend looking in proper way access database via wordpress' actions & hooks; can't think of whole lot of reasons need hit directly, , if did, using global $wpdb , methods available object handle else.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -