Preferred Use of home_url()?

This isn’t a problem but rather I am just curious to see how others are using this function. The codex does not really say a preferred method of use although it does provide some straight-forward examples. For example if my domain is example.com I can write any of these: <a href=”https://wordpress.stackexchange.com/questions/224062/<?php echo esc_url( home_url() ); … Read more

Unable to load static front page on home url

I installed wordpress in /wp/ directory. So in my blog every URL had /wp/ in it. I followed multiple articles(1,2) and was able to remove the ‘wp’ from URLs. before – example.com/wp/post-1-name after – example.com/post-1-name In permalink settings I have selected – post name – http://example.com/sample-post/ Now every url I open do not have /wp/ … Read more

What’s the difference between home_url() and get_home_url() from a developmental point of view?

Both functions return the website url. And, as home_url() needs sanitization (for example <?php echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); ?>), why it is this snippet of code, instead of <?php echo get_ home_url( “https://wordpress.stackexchange.com/” ); ?>, that we found in WordPress Codex and WordPress Template Twenty Nineteen ? 2 Answers 2 There isn’t much … Read more

How to remove “http://” When Echoing URL?

I’m seeking to echo the domain name (url) without the ‘http://’ (or ‘https://’). I’ve created the following: <?php $surl = bloginfo(‘url’); $findh = array( ‘http://’ ); $replace=””; $outputh = str_replace( $findh, $replace, $surl ); echo $outputh; ?> also another one (of many) I tried: <?php $surl = bloginfo(‘url’); echo str_replace(‘http://’, ”, $surl); ?> Seems like … Read more

Difference between bloginfo(‘home’) and home_url() and site_url()

I have been reading through Codex and other SO and SE posts regarding this. But I am confused. I used home_url() and site_url() to linking the site’s home and it gave same results. As I was using qTranslate for bilingual implementation. And had its language switcher. Found later, when clicked on the home logo (used … Read more

Getting the Site URL Including the Front Base

If my permalink structure is set to /blog/%postname%/, how can I retrieve a URL for my site which retrieves domain.com/blog/? With the permalink structure mentioned above, when using site_url();, it displays domain.com/ when I’m looking to easily get the site’s URL including the front base. Maybe I’m unclear about what the “front base” actually is. … Read more