07-27-2023, 10:13 AM
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]:
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]