Generally, they will return the same URL, as bloginfo( 'url' )
will call home_url
internally with any arguments, and the default first argument ($path
) of home_url
is the empty string. However, bloginfo( 'url' )
will apply an additional filter to it, namely the home_url
filter.
Common pratice is to use home_url
, indeed with esc_url
(even though home_url()
returning an invalid URL will yield bigger problems anyway :-)). In WordPress core, bloginfo( 'url' )
is practically never used anymore. Instead, home_url( "https://wordpress.stackexchange.com/" )
is used.
So, summarizing: use esc_url( home_url( "https://wordpress.stackexchange.com/" ) )
.