If it is post-thumbnail, it will return the ID:-
<?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?>
try this.
Related Posts:
- Only show first image in foreach loop
- Permanently remove first image from posts
- Using a javascript file to access a get posts array
- Styling images coming from another blog
- Recent posts with featured image or fallback image with permalink
- Best practice for migration friendly images in posts/pages?
- Reprinting tags with all attributes
- Redirect to another page using contact form 7? [closed]
- I’m unable to call img path using single quotes in an array?
- how to make an array of post id’s in is_single
- array_rand not working correctly?
- Update value of a associative array with update_post_meta
- Get list of posts from attachment
- Make sticky post with FacetWP
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- WooCommerce: write featured image dimensions to custom fields in product’
- Sorting list of sites from multisite network using wp_get_sites
- Debugging upload problem: What part of WP does actual image-resizing?
- How to upload imagick resource to media in wordpress
- Insert code when users come from an specific referer
- How to display related posts from parent category
- How do I get images (with a thumbnail preview) to show in search results?
- Assign a picture URL to a page via PHP
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- How to scale image with equal width and height without distortion?
- Escape post image attachments added to template
- Parsing php string in jquery [closed]
- Display post image with fancybox
- Echo URL of large version of Featured Image
- How can I use wp_query to show all product data using just the products ID?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Cannot display or echo alt text on featured image
- Call global variable array() in woocommerce child/template
- Populate dropdown with Child Pages based on Parent Page chosen
- Loop through categories and display posts title under each dropdown
- How to store post ID’s in cookie or session to display the same posts later
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- Post + form + action + results on the same page
- Why my image upload button is not working in wordpress widget area?
- WordPress function when file is uploaded, deleted or edited
- Display related posts without a plugin
- Count posts on multisite with blog id
- How to use if statement in an array? [closed]
- How to loop through all the attached images in a post, and get their url one by one
- How to show an entire post content and not also the excerpt?
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Get categories names as an array to use it in theme settings
- How to get the last category name of a child category?
- WordPress query undefined offset in loop
- WP_Query: getting posts where custom field exists
- Foreach loop inside an array_merge
- Getting posts to exclude from array
- get post id from wp_insert_post for get_template_part
- .html end of URl affected to SEO?
- Comapare get_user_meta value
- How can get all users by current user meta?
- Output category list inside array
- Update if post with specific title exists
- WordPress İmages Upload & Delete Error
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- How to internationalize header image?
- Add custom fields from different posts
- Advanced Query posts
- WordPress api post image raw data without being blank in media library
- Sending simple variable on single page to WP JSON
- My Custom Post Type AJAX Query is Returning no posts – why?
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- How do I stop an Image Address from loading in the Browser?
- Don’t update modified post date when user add a product review or comment?
- Limit the number of characters/words in an excerpt for a related posts section
- Posts missing on author page
- How to add a PHP scripts into WordPress
- Closing Comments conditionally in comments.php
- How to filter specific element of an array in wordpress/php?
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- Notice : Array to string conversion on array_intersect user meta
- How do if all posts has this category ID then do this
- Remove item from post_meta array via AJAX
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Getting error in sql query
- Display posts using post ID’s in an array
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- insert thumbnail image from php script
- How to find the function which is outputting Array
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- HTML in PHP problem [closed]
- PHP Use Declared array Variable inside already Declared Array
- Remove default Image Sizes
- Grabbing value of input field inside of array
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Generate and upload screenshot as featured image for user-submitted post
- transition_post_status hook, works – but not if the post is new