WordPress: How to get the Url of the Website

I want a function which gets a url of the website. Similar to this one: <?php bloginfo('template_directory') ?> But instead takes me to the URL of the website, so I can use it to link my homepage to the home button.

If there is a better way of how to link the home button just let me know.

Read More

Ryan

Related posts

Leave a Reply

4 comments

  1. Use get_home_url():

    The get_home_url template tag retrieves the home url for the current site. Returns the ‘home’ option with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If scheme is ‘http’ or ‘https’, is_ssl() is overridden.

    echo get_home_url();
    

    Almost all other WordPress environment info can be fetched through the get_bloginfo() function.

  2. I use this code for the site url from the [WordPress Codex][1]

    $url = get_site_url();
        echo $url;
    
    
      [1]: https://developer.wordpress.org/reference/functions/site_url/