WordPress blog url without http

If you want to show your WordPress URL without http, you can do it by a str_replace function in combination with the WordPress get_bloginfo(‘wpurl’) function, as follows:

Add al the protocols that you want to remove in an array, and then str_replace the get_bloginfo(‘wpurl’) function.

<?php
 $protocols = array('http://', 'http://www.', 'www.');
 echo str_replace($protocols, '', get_bloginfo('wpurl'));
 ?>

That’s it!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s