Scroll to top

How to get a site url in WordPress code?

Author
Conversation
Share on facebook
Share on google
Share on twitter
Share on linkedin

Getting the Site’s URL

Let’s say your site’s URL is http://example.com. If you want to print this out in the source, you can use the url parameter.

<?php bloginfo('url'); ?>

This works great for absolute link references. For example, if you wanted to reference your logo (let’s say the file name is logo.png) that is in a directory called images, you would do the following:

<img src="<?php bloginfo('url'); ?>/images/logo.png" />

The above outputs:

<img src=" http://example.com/images/logo.png" />

Recent Posts

envato iconUpwork Profile