wordpress url and site url code example
Example 1: home url wordpress
$url = home_url();
echo $url; // Output: http://www.example.com
$url = home_url( '/' );
echo $url; // Output: http://www.example.com/
$url = home_url( $path = '/', $scheme = 'https' );
echo $url; // Output: https://www.example.com/
$url = home_url( $path = 'example', $scheme = 'relative' );
echo $url; // Output: /example
Example 2: current url wordpress
global $wp;
echo home_url( $wp->request )