You can just update your function to pass the post_id as a parameter.
function w_thumbnail_src($post_id) {
if (has_post_thumbnail($post_id)) {
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'emphasis');
echo $thumb[0]; // thumbnail url
}
}
Related Posts:
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Prevent “main” WPMU site_url() being returned in functions
- Custom page with variables in url. Nice url with add_rewrite_rule
- Automatically set the featured image
- Get recent posts with thumbnail
- Is it possible to use a forgot password url filter?
- Create Custom URL structure for specific Post category
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Add options to featured image
- Linking thumbnail to full size image
- Generating Responsive Background Image Sizes in PHP
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Add a Post Thumbnail to an RSS Feed with custom size
- How can I rename the WordPress AJAX URL? [duplicate]
- Make WordPress size and name images for Retina.js
- Why are image thumbnails cropped proportionally (not per dimensions)?
- the_post_thumbnail fallback using hooks
- Display height and width properties with the_post_thumbnail() or related function
- Setting featured image with function, 1 part not working
- Removing the first image in content
- How to set the jpg image compression for specific thumbnail sizes?
- Function to auto-set a featured image that is already in use
- img width and height attributes being set by get_the_post_thumbnail
- Get the 5 lastest Featured Posts from a category
- How to display a default image for post thumbnail using functions.php?
- Change size and crop medium_large images
- Ninja form Redirect depending on text field content [closed]
- Getting Featured Image Caption to Only Show if Populated
- wp_get_attachment_image function size argument not working if I also add a custom class
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Add Featured image column into wordpress admin on pages AND posts
- Post thumbnail not showing in WP admin area for custom post type
- Overwriting Parent Theme’s Image Sizes
- Backstretch.js and thumbnail sizes to reduce loading time
- set_post_thumbnail when user is not logged in
- How to stop twenty fifteen theme from cropping featured images?
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- wp-comment author- url +, email filter hook
- Removing custom meta data
- show first 3 thumbnails of posts in different sizes [closed]
- WordPress on AWS Auto scaling and ELB giving 503
- WordPress converts media extention URL automatically to video player
- Set spesific size of featured images
- meta tags doesnt fetch data from permalinks
- Can’t generate thumbnail images
- Redirect to another page using contact form 7? [closed]
- It does not work concatenation in function.php
- Get arguments from URL
- How to retrieve the current post’s generated featured image size?
- Check if the image size is available and if not use ‘full’ image size
- Add unique id to Preview URL
- is there a way to remove featured image from blog page and single page
- How to hide image-url if no attachment?
- Can set_post_thumbnail be used to remove a thumbnail?
- Can’t locate custom image sizes defined by child theme
- How can I set the SRC URL of the custom logo image?
- Need to convert image url to a Base_64 data url with wordpress function..
- How to add a new image size and apply it to posts only?
- Protect get_query_var from manual input in url
- Problem with images URL after filter applying
- Show Featured Image in else statement
- Change custom featured image size in twentythirteen child theme
- resizing of thumbnails not working
- Featured Image keeps cropping
- How i can get the URL?
- show all the posts thumbnails
- struggling with syntax for the_post_thumbnail();
- Create Custom URL structure for specific Post category using Post ID instead of post name
- Custom image sizes showing in Classic Editor only when upladed directly to post
- Fetch URL parameter
- how can I change all wordpress media file url to custom cdn url?
- Custom route and extract data from slashes and parameter
- Which filter fires upon setting a featured image
- reWrite wp-content url to point on my cdn
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- How to Override Page Template if URL matches query?
- Add #primary at the end of navlink permalinks on single posts
- remove_filter function to unhook twentysixteen parent theme function
- Can You Set A Minimum Image Dimension For Resizing Images?
- Set URL Parameter Post Layout As Default
- Featured image on archive page based on post type
- Printing medium sized image
- Sticky – Featured Image
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Frontend Feature image upload not work
- Best way to add image to recent posts widget?
- Slider Thumbnail Size Issue [closed]
- Remove Featured Images from Posts Older Than a Certain Date
- Instead of using $post, how do i get the thumbnail image of the $post
- How to add a meta information to the URL?
- Apply height and width for the_content() inside youtube video tag
- Set thumbnail from URL, by grabbing image in functions.php
- add_theme_support not outputting thumbnails
- Full size image option removing problem
- How do I change the URL returned by next_posts_link()?
- Function in functions.php by url
- Image width issue in IE [closed]
- image_size with respect to aspect ratios
- Is mytheme_post_thumbnails() still necessary?