I am new in wordpress, Right now i am working with "my server", and my current domain/main url is like "myurl.com/myproject"
And later i will move project(wordpress) to another server and url will be like "myurl.com", so i want to know that right now how can
i manage this ? in other words which code should be use for include "css,js,images etc.." ?
I tried with following code not showing "http"
echo $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
2
Answers
You can get your domain URL via
home_url('/')
home_url and get your current directory via PHP function and constantbasename(___FILE___)
FILE_ basename or use WordPress function to create your desire dircetory pathget_template_directory().'/your_dir'
get_template_directory or URLget_template_directory_uri().'/your_dir'
get_template_directory_uriHere you go:
I build this function to work in one my plugin that cover all WordPress and PHP versions.
Tested on few thousand installations.
Feel free to use it!