root - Get WordPress installation folder path -


is there way path wordpress installed?

i using following:

$root = realpath($_server["document_root"]); 

it fine www.example.com -> /usr/local/pem/vhosts/165312/webspace/httpdocs

it not fine www.example.com/blog since need hard code folder name (blog).

later found way using this:

$iroot = getcwd(); $folder = explode("/", $iroot); $dir = $folder[8]; // know 8 $root = realpath($_server["document_root"]); require "$root/$dir/wp-blog-header.php"; 

but still lot of complicated stuff. there simple way wordpress installed (the path) without hard coding?

note: 1 wordpress functions not work since somehow outside wordpress. noted on last example, whole point of determine wordpress installation path require "wp-blog-header.php"; on multiple wordpress installations each installation uses different folder (example.com/blog-one , example.com/blog-two), not wordpress mu or multi site.

note: 2 if instead of require "$root/$dir/wp-blog-header.php"; use require "wp-blog-header.php"; work long file in same folder, in case file in different folder.

use abspath constant:

<?php echo abspath ?> 

this should print wordpress path.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -