YogeshChauhan . com

How to retrieve homepage URL in WordPress?

in WordPress on October 16, 2020

We can use home_url() function from WordPress to get the homepage URL, considering the front end is accessible.


home_url( $path = ' ', $scheme )

where $path can be string and $scheme can be null or string

Note: Path is the relative path to the home URL.

$scheme accepts 'http', 'https', 'relative', 'rest', or null and the default value is null.


$url = home_url();
echo $url;



$url = home_url( '/' );
echo $url;

// Output


$url = home_url( $path = '/', $scheme = 'https' );
echo $url;

// Output


$url = home_url( $path = 'yogeshchauhan', $scheme = 'relative' );
echo $url;

// Output 


Credit: developer.wordpress.org


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

What are Web services?MiscCrypto.getRandomValues() method in JavaScriptJavaScriptHow to hide and show menu on scroll using JavaScript and CSS?CSSIs there a difference between SCSS and Sass?SCSSHow to add a Pie Chart in Angular App?AngularAlternate Style Sheets in CSSCSSfirst-of-type and last-of-type selectors in CSSCSSHow to create a new HTML element programmatically using JavaScript?HTMLHow to load a module with configuration in SCSS?SCSSHow to find the HCF or GCD and LCM of two given numbers using Swift?SwiftHow to get Current Hour, Minute and Second in JavaScript?JavaScript4 different ways to create JavaScript ObjectsJavaScript