Use get_template_directory_uri()
print get_template_directory_uri() . '/image.jpg';
In child themes use get_stylesheet_directory_uri()
if you have replaced the image.
In a shortcode this would look like this:
<?php
/* Plugin Name: Theme URI Shortcode */
add_shortcode('theme_uri', 'wpse_66026_theme_uri_shortcode' );
function wpse_66026_theme_uri_shortcode( $attrs = array (), $content="" )
{
$theme_uri = is_child_theme()
? get_stylesheet_directory_uri()
: get_template_directory_uri();
return trailingslashit( $theme_uri );
}
Related Posts:
- Shortcode for a link and thumbnail
- How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
- Programmatically get images by URL and save in uploads folder
- Function to get URL of original uploaded image – full size
- How to have different captions for same image, for galleries?
- How to reference a theme image in a stylesheet?
- Featured image shortcode
- Mixed content warnings after changing site adress from HTTP to HTTPS
- Always use for post images
- Preview Image Path in Admin Section
- Insert Images at Master Uniform Height
- How can I make all gallery images to open in a new window?
- How to display a shortcode caption somewhere other than the_content
- Why would image paths in wordpress suddenly change?
- Remove the http protocol from images
- get attributes/part of the gallery shortcode
- @wordpress/create-block image url in css
- Editing built in Gallery shortcode to filter by categories
- WordPress url image redirect to the homepage
- Broken urls with http site and https wp-admin
- A way to change image urls in post to cdn image url?
- How to change image url?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- Add attribute to caption shortcode from custom attachment field
- Get an image’s alt text in a shortcode using the image URL
- Update image links in database
- media_sideload_image with rewritten urls?
- Is my code is right to make image shortcode
- Set Post Image Using Shortcode
- Turn off image captions in gallery view?
- Undefined index: sui_image_caption in [closed]
- add_shortcode to capture URL screenshot not loading correctly
- How to add an image to a custom url?
- Ho to add “Create Slider” option to default “Add Media” popup?
- images not showing after transfer
- Change media URL (images)
- Don’t show images inserted into content
- Redirect to another page using contact form 7? [closed]
- Random image loader
- Load Gallery Images with Title on Homepage BX Slider
- How to redirect homepage to actual URL?
- Clicks registering on Preview DNS site
- Weird failing request
- Need to convert image url to a Base_64 data url with wordpress function..
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Using a .pdf file as a page in wordpress
- How to get image URL from media_sideload_image?
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- Exclude image url from search query
- Redirect Image Url to a page via htaccess
- Image and shortcode not showing in excerpt
- How to pass on a value as parameter via url to another page
- How to replace post image url before posting using api?
- insert og image link in wordpress post
- Hide or mask the url to an image
- Shortcode not work in picture source srcset tag
- Glitched page redirects to image
- change the h3 subtitles of the wordpress gallery shortcode
- i want to change URL of WordPress image or rewrite in runtime
- How to show a full page when someone links directly to an image on my site
- Post Images are not showing up whenever I use shortCodes in my posts
- Bypass wp_safe_remote_get()?
- WordPress Shortcode to display featured images only
- Which tools should I use for a gallery that uses an API and url for the path of the images?
- List sub pages with custom field content converting image ID to URL
- Gallery with shortcode not showing
- Change the image for a certain URL
- Setting name of attachment URL
- Search and replace image urls in posts
- Protocol relative url not pulling up images on IE, FF, and OPERA
- Broken image URL
- How do I mitigate the forward slash problem for URLs of images after a WP migration?
- Images in sub-pages fail to load
- get_post_custom: get image URL instead of image ID
- Are image addresses security relevant?
- Remote Image (from URL) as Media Library element
- Can I turn an image into a button?
- WPALLIMPORT Exporting images from repeater field [closed]
- get_post_gallery_images returns thumbs . I want full size
- Generate image size, based on the image-orientation
- How to disable the suffix “-scaled” which is being added at the end of each uploaded image?
- Add a new data attribute in tag
- Why no images on a fresh WordPress installation?
- How to stop thumbnail generation from some images and different size thumbnail generate
- Problem with images when no dimension in the URL [closed]
- some images not appearing on the website after migration [closed]
- How do I get my main image to stretch the full length of the screen?
- HowTo: develop WP template with dynamic background image
- What did I do WRONG?
- Add retina “2x” in attribute “srcset”
- Change logo image condition based on url
- Hiding Media Source Links
- Why is my table background image not showing in wordpress?
- WordPress Multisite: Images moved to /sites/1?
- wordpress images not showing properly
- How do I embed an image at actual size?
- Storing images on a local site
- page url in shortcode
- Set image dimension for WP_Customize_Image_Control images
- Images uploaded in customized gallery do not link to media