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’
- How can I split my query result in 2 arrays?
- Display an image based on field value
- Else/If Statement to Display Photo Descriptions
- Loading Posts & Category with Ajax
- Multidimensional Array
- Four posts per row [closed]
- Separate array output into a
- Update if post with specific title exists
- Add valid XHTML closing img tags to WordPress galleries
- How to set a featured image (thumbnail) with PHP?
- Need help removing […] after excerpt
- Convert canvas to image and upload image to server
- Get css class of menu item in custom menu structure
- show recent posts php code error?
- Error display post thumbnails for previous and next post
- WP_Query() load selected post
- Controlling image output size ACF repeater [closed]
- Post to WordPress from another Server via PHP
- Dynamically adding filters
- Order a WP_Query by meta value where the value is an array
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- WordPress İmages Upload & Delete Error
- Unable to render custom field after attempt to generate a list of recent post in page template
- how to edit a specific post slug using a php code?
- form $_post action value gets truncated after it passes through two forms
- Only load certain artists on this page
- add the value of a variable returned in a while loop [closed]
- 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 when I create a new post I found 2 record related to this post into the posts database table?
- Saving a post ID to use in a form elsewhere on website
- WordPress Search
- Wrap posts p tags in div
- How to make sure relative URL works when site is not on root domain?
- Get URI from PodPress using PHP
- 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?
- using images in next/previous_post_link [closed]
- Finding and removing duplicates within WP Arrays
- Adding a ‘style=’ bit to image_send_to_editor output
- How to get the next and previous image title from attachment or gallery?
- Using multiple variables to assign categories to an array
- Convert all uploaded PNG files to PNG-8 format
- foreach repeat html structure after every nth for attachment [closed]
- CSS images don’t show up with bloginfo
- Categories Listing and Highlighting current category item
- how to show images without passing it to timthumb.php file for resizing
- How to internationalize header image?
- Custom functions for string data calculations
- Add custom fields from different posts
- Prevent post from being published and show error
- Some problems in custom widget
- Wp Query : Order by distance lat,lon
- Displaying images outside the content
- Repeat a function with 24hrs gap for n number of days
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- MySQL Query Returns Array () In Shortcode
- Checking page before applying image restrictions while uploading
- remove specificly the last tag in all posts
- Pagination in single.php
- Pagination at category doesnt work with same name of page
- Add posts to custom table in database instead of wp_posts
- get value from get_post_meta then reuse it in another get_post_meta
- Edit and delete permissions pages and posts
- understand what code is doing when prepending /blog
- How to show categories and date on posts
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Generate images with html2canvas and the woocommerce api
- Advanced Query posts
- Change extension to .jpg when webp is not supported
- Convert a column of a table containing an Array as response in HTML
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- My worpress search page is showing no results
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- WordPress Post Block Element not properly parsed with the_content filter
- duplicate posts with ajax load more wordpress
- WordPress api post image raw data without being blank in media library
- Filter wordpress posts without searching the keywords in the post content
- Build A Custom SQL Query for WordPress Search
- Sending simple variable on single page to WP JSON
- Prepend to all image URLs with PHP, only for mobile devices
- Retrieve alt text by referencing the img src
- Create an array with all the links of the years’ archive (of a custom post type)