Reputation: 193
I'm currently developing a new site on Wordpress to replace an old Drupal site. The site is currently being developed on 'dev.website.com', and will be moved to 'website.com' once completed.
I'd like to use a relative image path like 'images/logo.png' instead of the absolute path as it'll make the switch a lot easier, as I won't have to manually remove 'dev.' before every single reference to a file path on the site.
Is there a plugin to do this, or a setting within the Wordpress admin itself? I've looked at loads of articles but they seem to be pretty complex for what I thought could be a simple fix.
Any help would be massively appreciated!
Upvotes: 0
Views: 358
Reputation: 51
Here is simple solution for importing images
<img src="<?php bloginfo('template_directory');?>/images/image.jpg">
Upvotes: 2
Reputation: 1793
I always use <?php bloginfo('stylesheet_directoy'); ?>/images/image.jpg
I create a lot of child themes and this works perfectly.
You can also define a constant with define(IMGPATH, STYLESHEETPATH . '/images');
and use something <?php IMGPATH . '/logo.png';
STYLESHEETPATH
is a constant that WordPress uses.
Upvotes: 0