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
- 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?
- How to get Poster (thumbnail) Image of Video
- 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?
- 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
- Randomly Assign an Image’s Alt Text Based on Data From Post
- WP dynamic featured image – Can’t get second featured image url
- 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
- WordPress style.css not updating, only after theme reload
- ‘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?
- Apply class to every third list item? [duplicate]
- Automatically add images to a menu
- 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
- 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
- Get the alt text of the image in a array
- Trying to change featured image from 180×180 to full width on home page
- 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
- wp_query – Exclude the first thumbnail from lazy loading on archives
- How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?
- Replace background image with post thumbnail in shortcode
- How to put 2 php codes in functions.php without site crashing
- How to add WordPress Featured image in tag ..?
- Split post or page content in two or more columns
- Gutenberg blocks shortcodes compatibility
- How to bind each “the_content” elements to a custom variables
- WordPress generate images size after upload
- Check If bootstrap last column is even or odd (using ACF custom field)
- Add a default style if no Featured image is selected
- How to programmatically set existing image in media library the featured image for a post in wordpress
- Having trouble with customizing blog posts on the home page
- custom post type not showed with bootstrap 4 modal and template part
- Posts in two different columns Bootstrap
- How to link featured images in single.php for only non-logged-in users?
- PHP code printed into CSS classes
- Thumbnail wouldn’t scale to size properly
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- making a search.php query
- Problems with the WordPress loop [closed]
- get_post_thumbnail_id returns a negative number
- Custom Thumbnails [closed]
- Retrieving specific images from Media Library
- Basic PHP question (displaying post title over thumbnail) [closed]
- 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
- Setting post thumbnail sizes in template file and functions.php
- add if statement to the featured image
- Remove default Image Sizes
- Generate and upload screenshot as featured image for user-submitted post