Because $imgID
is an array of post objects. Instead of:
return $imgID;
You need:
return $imgID ? key( $imgID ) : 0;
Since get_children
returns an array of posts indexed by their ID, you can simply use key
to return the value of the first one.
Related Posts:
- How to recognise on which site the content is being rendered?
- has_post_format() vs. get_post_format()
- What difference does it make if I enable support for video post format?
- How do I remove the post format meta box?
- Adding post-formats to Twenty Ten child theme
- Is there a real life use case for post formats except for microbloging?
- Renaming post formats after Gutenberg
- What is the recommended behavior for the post formats?
- Custom Post Formats
- Target all posts that are NOT aside or link post formats
- Link Featured Thumb to Attachment Page, If Possible
- Filter the first from Quote Post Format
- Displaying all Video Post Formats to Page
- Display Post Format as a String
- Different markup for each post format
- post formats – how to get the relevant content part?
- Post formats for Pages not saving
- Is there any problem if I use get_template_part like this?
- How can I remove the first video from a post and feature it?
- previous_post_link/next_post_link disappear when excluding by post_format
- Usage of post_formats
- how to get list of post formats supported by theme?
- Formatting Standard Post Format
- If post-format == ‘gallery’ conditional
- Adding new post format on plugin activation
- post formats – where’s the difference: “aside” vs. “status”?
- how to retrieve the image title for image Post Format
- About post format
- Smart post format loop problems
- “post-format” code snippets list [closed]
- wordpress post formats
- How to display quote format by preg_match function?
- I would like to have a quote page just to show quotes
- Return only one post format in index.php [duplicate]
- How to display list of video post on video section?
- Paste from word not preserving formatting
- How to treat post formats?
- Post formats and template hierarchy
- Change standard post format metabox
- Next Post Link in format
- Mass post format changer?
- Displaying cf post formats with oembed
- Custom formatting
- The the_post_thumbnail without srcset?
- Is there a simple way to just insert a link to an image (without inserting an image)?
- Watermarking Images with WordPress with WP_Image_Editor
- Auto-modifying original [full size] images
- Crop image to horizontal or vertical by code based on image size
- Open the attachment details modal
- Count number of posts which exist in 2 taxonomies?
- Change default ordering of taxonomy terms – pre_get_terms
- How to Display Featured Image Title and ALT Attribute
- get custom image size
- Add Small Image Size to Media Settings
- Combining media queries with image sizes
- Custom Image Thumbnails of Different Sizes
- How to check if there is image title, caption, description?
- How to remove attachments size attribute [duplicate]
- WordPress adds extra width to post images container boxes
- Unread Repeater field IMG alt not working
- Help With Custom Image and Text Widget
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- wordpress post pagination with image buttons?
- How to upload multiple files/images when developing a wordpress plugin?
- How would one change the default url structure of attachments?
- Disable lazy loading on specific images
- Server B handling add_image_size() differently than Server A
- Get post format and use it as a CSS class in different spans
- wp_get_attachment_image_src returns incorrect URL on multisite
- get_children returns older images
- Large amount image data transfer
- Need to convert image url to a Base_64 data url with wordpress function..
- How to display post title inside thumbnail?
- Why do I have blury images in WordPress
- How to fix WordPress images not showing up in local hosted XAMPP server?
- WP_Query tax_query – Show results if child has parent X
- How do I get only a certain number of images from a post (minus the featured image)?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Query all posts under one taxonomy? Why is my code not working?
- Checking page before applying image restrictions while uploading
- How to increase media image scale limit?
- Pinterest button shows image options from different posts
- How do I get WordPress to create resizes of a supplied default image in a theme?
- Blank image thumbnails in media library
- Getting extra image links in code with wp_get_attachment_image
- Best way to manage theme images
- Dinamically modifying attributes of images on posts
- How do I routinely extract the thumbnail of the most recent post?
- Featured images are cropped on index and post page
- Issue uploading images
- Remove “align” attribute on images
- Custom single.php files for different post formats
- How do I change a Themes Header Image?
- Blurry Images WordPress 5.8.1
- How to pass >= condition filter to my year custom tax_query
- How to show file size of featured image? [duplicate]
- How to add height and width dimensions automatically to archive descriptions
- WP_Image_Editor – How to save the new size of the image in the sizes metadata
- Is is possible to append .webp to srcset images using wp_filter_content_tags()?
- Could a very long article slow down all website and wpadmin?