Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current domain and directory name dynamically php wordpress

Tags:

php

wordpress

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']);
like image 701
Amy Avatar asked Dec 05 '25 16:12

Amy


1 Answers

You can get your domain URL via home_url('/') home_url and get your current directory via PHP function and constant basename(___FILE___) FILE_ basename or use WordPress function to create your desire dircetory path get_template_directory().'/your_dir' get_template_directory or URL get_template_directory_uri().'/your_dir' get_template_directory_uri

like image 87
Abdul Hanan Avatar answered Dec 09 '25 14:12

Abdul Hanan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!