img
Retrieve Site URL

Use site_url() to get the site’s base URL dynamically:

				
					<?php echo site_url(); ?>

				
			

Example Output:
http://localhost/drpam

Use home_url() to get the site’s home URL dynamically (useful if WordPress is installed in a subdirectory):

				
					<?php echo home_url(); ?>
				
			

Example Output:
http://localhost/website

If you need the URL of your theme folder:

				
					<?php echo get_template_directory_uri(); ?>
				
			

Example Output:
http://localhost/website/wp-content/themes/your-theme-name

If you’re working with a child theme:

				
					<?php echo get_stylesheet_directory_uri(); ?>
				
			

Example Output:
http://localhost/drpam/wp-content/themes/your-child-theme-name

If you need the URL of the uploads directory:

				
					<?php echo wp_get_upload_dir()['baseurl']; ?>
				
			

Example Output:
http://localhost/drpam/wp-content/uploads

Related Posts