I am developing a theme for wordpress. And I have many images in 'images' folder. But when I take the page in browser it is not comming.
My code is
<ul>
<li><a href="#"><img src="images/mindset.jpg" width="145" height="32" /></a></li>
Is there any function for getting the image path in wordpress ?
Finding Your WordPress Image URLs from the FrontendOpen a page or post where the image is published and locate the image. After that, right-click on the image, and select 'Open image in new tab' option. Once the image opens in the new tab, look at the URL in the address bar. That is your WordPress image URL.
Add an Image from a URL in WordPress: Overview To add an image from a URL in WordPress to a post or page, click into the post or page where you want the image to appear. Next, click the “Add Media” button to open the “Insert Media” dialog box. On the left side of the dialog box, click the “Insert from URL” link.
You need to find the one with /wp-content/themes in the URL. You may be able to find the Theme's URL or Theme Author's URL here which will lead you to the theme used by the website. Many WordPress sites use child themes to customize their websites.
src="<?php echo base_url()?>your_theme_dir/image_dir/img.ext"
As well
src="<?php bloginfo('template_url'); ?>/image_dir/img.ext"
get_template_directory_uri();
This function will help you retrieve theme directory URI, and can be used with your images, your example below:
<img src="<?php echo get_template_directory_uri(); ?>/images/mindset.jpg" />
I had to use Stylesheet directory to work for me.
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/image.png">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With