Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 531 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wordpress - Get root directory?

#1
How can I get the root directory of my site? I want to use it as the `src` for `<img>`.

For example If I install the wordpress on `www.mysite.com/blog/`, the root is `/blog`.

But If I install it to `www.mysite.com/test/blog`, the root is `/test/blog`.

I tried to use the snippet from [this question][1], but it returns the whole path as seen in FTP. So instead of returning just `/blog`, it returns `/home/public_html/blog` which won't work if used as `src` in image tag.

Any solution? Thanks.


[1]:

[To see links please register here]

Reply

#2
You may have better luck over at the [Wordpress Stack Exchange][1] site :)

And this suggestion to use `ABSPATH` didn't help on that thread?

[To see links please register here]


[1]:

[To see links please register here]

Reply

#3
site_url() return the path with http, in some cases, it is not allowed if the server turns off url inclusion. You can use the function below to get the root path of wordpress installation folder:

function get_wp_installation()
{
$full_path = getcwd();
$ar = explode("wp-", $full_path);
return $ar[0];
}
Reply

#4
You may use `site_url()` (eventually with `echo`) to get absolute path with server name and directory. Also, have a look at [wordpress documentation][1] about similar functions & what they provide.


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through