web hosting
build a website

WordPress relative link to template folder

Aug 15, 2015   //   by Anthony Devine   //   Website Development tips  //  No Comments

In Wordppress you may want to link an image or css file in your theme directory to your site like the logo or main style sheet. Instead of adding in an absolute link into your php file which includes your domain name you can use the following code for a relative link. This is much better as you may end up changing your site domain name. I found it very useful as I would usually create a site under a test domain before moving it over to the new one.

<?php bloginfo('template_directory');?>/styles.css