It seems you are using this outside the loop then use get_the_post_thumbnail
to get the featured image for any post by supplying post id.
So your code will become this.
<?php
if ( has_post_thumbnail() ) {
echo '<a href="' . get_permalink( $post->ID ) . '" >';
echo get_the_post_thumbnail( $post->ID, 'my_feature_image', array( 'class' => "someName" ) );
echo '</a>';
}
?>
Related Posts:
- add class to background image
- How to display thumbnail if post is assigned one otherwise not
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- PHP/Manual use of images? – 2 Questions
- Adding Featured Image to Post programatically
- How to upload imagick resource to media in wordpress
- How to add a featured image to a existing post via php?
- How to use SRCSET with get_the_post_thumbnail()?
- Adding featured image via PHP
- WordPress loop specific thumbnail size
- How do I get images (with a thumbnail preview) to show in search results?
- fallback image for featured image
- How to get Poster (thumbnail) Image of Video
- WP Insert Post function – Insert Post Thumbnail
- Display All Post Attachments and Assign Class to the Last Image?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Assign a picture URL to a page via PHP
- How to scale image with equal width and height without distortion?
- Featured image fallback link to permalink
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- How to Display Image Meta underneath EVERY image in EVERY post
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- custom shortcode will not display the wrapped content
- How can I add pagination and how can I change thumbnail size?
- Echo URL of large version of Featured Image
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Trying to add attribute to my posts’ featured image
- Multiple WordPress Menus that will only display all pages
- Recent posts with featured image or fallback image with permalink
- Randomly Assign an Image’s Alt Text Based on Data From Post
- WP dynamic featured image – Can’t get second featured image url
- Set the background to a default image if there isn’t a specified “featured image”
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- Is it possible to use Data URI image to set a post thumbnail?
- WP Post-Thumbnail
- Display custom post type title as text if post thumbnail is not available
- WordPress Multiple Navigation bars
- Using Select HTML in Bootstrap Popovers
- Add class to group inner container
- WordPress style.css not updating, only after theme reload
- post thumbnail, conditions, else wont work
- ‘Post-thumbnails’ feature does not seem to register
- height should be set to auto to avoid pixelation in the post thumbnail function
- Three Questions with Twenty Eleven theme
- Display related posts without a plugin
- WordPress function and string as variable?
- Resize image to specific dimension (X to Y ratio)
- Apply class to every third list item? [duplicate]
- Automatically add images to a menu
- My website is not showing Footer section
- Using featured image of blog archive page
- if custom field doesn’t exist, use post thumbnail instead, as image background
- Bootstrap Carousel HTML structure and funny output [closed]
- Help Fallback (thumbnail)
- Handling repeater data
- Get featured image with custom size outside WordPress
- How to add post thumbnail dynamically using Jquery?
- Posts are not looping through correctly
- Else/If Statement to Display Photo Descriptions
- How to set a featured image (thumbnail) with PHP?
- How to change thumbnail src attribute?
- Error display post thumbnails for previous and next post
- Fallback image URL if no featured image exists via a shortcode function
- How to replace URL protocol using PHP?
- Call featured image url
- How to pick “full/thumbnail” images in the loop?
- Generate responsive post thumbnails of same size
- How to Make Thumbnail of Post Stay Animated
- Why in this WordPress theme I can’t see the Main Menu?
- Get the alt text of the image in a array
- Trying to change featured image from 180×180 to full width on home page
- Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- WordPress navigation wont appear with wp_head
- Need to add a post’s featured image to a section on the frontpage
- I can’t set image ad fatured programatically
- Bootstrap 4 Carosuel with ACF Repeater field
- Add Featured Image to Existing Post
- wp_query – Exclude the first thumbnail from lazy loading on archives
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- News and Featured image
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- add bootstrap modal after login in wordpress
- Overwriting a Shortcode
- featured post as div background
- Post Thumbnail on Single (if elseif else)
- Display WP posts in 3 responsive columns
- the_post_thumbnail unless video id is added
- How to echo a different field if another field is empty?
- Setting post thumbnail sizes in template file and functions.php
- How can i give a download link to the thumbnail or featured image
- add if statement to the featured image
- How to crop featured image in different sizes?
- Remove default Image Sizes
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Generate and upload screenshot as featured image for user-submitted post
- How can I display a layout differently depending on whether the user is on Mobile or PC?
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?