Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the image url in a Wordpress theme? [duplicate]

Tags:

php

wordpress

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

index.php

<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 ?

like image 389
Linto P D Avatar asked Jul 16 '10 07:07

Linto P D


People also ask

How do I find an image URL 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.

How do I give an image a URL in WordPress?

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.

How do I find my WordPress theme URL?

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.


3 Answers

src="<?php echo base_url()?>your_theme_dir/image_dir/img.ext"

As well

src="<?php bloginfo('template_url'); ?>/image_dir/img.ext"
like image 64
Sadat Avatar answered Oct 18 '22 23:10

Sadat


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" />
like image 19
Allen Avatar answered Oct 19 '22 00:10

Allen


I had to use Stylesheet directory to work for me.

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/image.png">
like image 7
Ian Avatar answered Oct 18 '22 23:10

Ian