WordPress: How to link an image into a theme

Created at: January 27, 2013; Last update: October 17, 2013

The new themes in WordPress are so good that most of the time you don’t even need to know html or css to make a change.

But now and then appears the need to change something important like changing the logo of your blog, and the only way you can do that is by changing the theme in in editor.

Although seems a simple task, if you’ve just started developing WordPress themes, you’re in a quite a hurdle.

So, you want to display a logo on your blog

First you will upload your logo image on the server. I’d advise you to upload your logo inside the theme’s images folder which usually can be found inside “public_html/wp-contents/themes/your_theme/images”. If you have your blog inside another folder, you will figure out where that folder is.

After uploading the file, you would probably think that you can insert the logo image in the pages by simply writing a relative path to your blog, like this:

[javascript src=”https://snipt.net/embed/baa260954ec50ea20836d05b3a95aad6/”]

But if you do that, it won’t work, no matter how many directories you escape. That is because the WordPress .htaccess file doesn’t allow you to access that file.

The solution is to use one of the many functions WordPress has: bloginfo(‘template_directory’).

So, it goes like this:

[javascript src=”https://snipt.net/embed/c57d7275057a90413967c16c63af8ce5/”]

Leave a Reply

Your email address will not be published. Required fields are marked *

No spam? * Time limit is exhausted. Please reload CAPTCHA.