php-wordpressHow to get the current URL in WordPress using PHP?
The current URL in WordPress can be retrieved using the home_url()
function. This function returns the home URL of the site.
Example code
$current_url = home_url();
echo $current_url;
Output example
https://example.com
Code explanation
home_url()
: This function returns the home URL of the site.
Helpful links
More of Php Wordpress
- How to increase the upload limit in WordPress using PHP?
- How to create a snippet in WordPress using PHP?
- How to run an SQL query in WordPress using PHP?
- How to use get_header in WordPress using PHP?
- How to disable PHP warnings in WordPress?
- How to send an email using PHP in WordPress?
- How to check the PHP version in WordPress?
- How to use the WordPress REST API with PHP?
- How to redirect to another page in WordPress using PHP?
- How to create a menu in WordPress using PHP?
See more codes...