php-wordpressHow to get the site URL in WordPress using PHP?
The site URL in WordPress can be retrieved using the home_url()
function in PHP. This function returns the home URL of the site.
<?php
echo home_url();
?>
The output of the above code will be the home URL of the site.
Code explanation
home_url()
- This function returns the home URL of the site.
Helpful links
More of Php Wordpress
- How to use get_header in WordPress using PHP?
- How to disable PHP warnings in WordPress?
- How to create a menu in WordPress using PHP?
- How to run an SQL query in WordPress using PHP?
- How to add a shortcode in WordPress?
- How to use the WordPress REST API with PHP?
- How to format a date in WordPress using PHP?
- How to increase the upload limit in WordPress using PHP?
- How to create a snippet in WordPress using PHP?
- How to redirect to another page in WordPress using PHP?
See more codes...