With WordPress themes, where do I store the images and files relatively?

Let me answer your question with a question: Are these images part of your template or for general purpose?

The WordPress theme “Responsive” has images files all over its theme folder. The theme should be at yoursite.com/wp-content/themes/responsive. In that theme folder there are a few folders with images: The obvious “images”, also “icons” and “includes/images”.

Now, let’s address some of your points.

YES, you can use relative urls for your images, but only in your CSS files. These images must be relative to the theme folder. There are some rare cases people add static HTML files in their themes, which relative paths may work.

NO, you can’t use relative paths in your php files, and even if you could, they could break at the slightest alteration. Use WordPress dynamic functions before your relative paths to ensure they don’t break. If you’re adding your image from the dashboard editor, you must always use absolute urls. This would be no problem, since every image you store in your media library gives you the absolute url when you click “edit” on them.

Now there’s a folder where all your non-template images are stored, yoursite.com/wp-content/uploads. You can change this folder in your Dashboard settings > media. The option appears as “store uploads in this folder”. You can choose a folder like yoursite.com/images (but you must create that folder first).

enter image description here

Leave a Comment