Where do you want to use this URL?
It's a bit unclear what you want to do, and where you want to use your URL.
In a theme's code
You can use get_template_directory_uri() in your theme code to get the URL of your theme. To get the URI of wp-content/themes/<your_theme>/image/image.jpg
:
<img src="<?php echo get_template_directory_uri() ?>/images/image.jpg">
You should not rely on absolute URLs in the case, since linking to /wp-content/themes/...
relies on Wordpress being installed in a particular folder.
To get the URLs of files in you wp-content/uploads
, you can use wp_upload_dir in a similar fashion. But if you're doing that, you're probably doing something wrong.
In a post
Don't use relative URLs. Use the absolute URL of the asset (for uploads you can get it from the Media Library, for other things, you'll have to figure it out). The content of a post can potentially be viewed on "any" URL (e.g. in an RSS feed) in which case relative URLs make little sense.
What goes where?
If the image is part of your theme (for example a background image), it should go in your theme's folder (possibly a subfolder named images
). Same goes for CSS files, Javascript and so on. The built-in twentyeleven theme is a great resource: Check out its folder layout and header.php
If the image is an upload, it will go into Wordpress's uploads folder. You should only use uploaded files in your posts/pages -- they are part of the website's content, not code.