#26812 closed defect (bug) (worksforme)
Unable to get attachment information in post or page .
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.8 |
Component: | Media | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description (last modified by )
Hello Sir
I am explaining this issue step by step.
- Create new post or page.
- Upload few images and few videos.
- Insert 1 image and 1 video.
- Publish this post.
- Edit this post and insert another video and image.
- Update this post.
Now on front end, index.php page I want to show attachment information associated with images, videos like title, description. I am using following code inside loop.
<?php $mchilds =& get_children( array ( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => 'any', )); //print_r($mchilds); ?>
Resulting array $mchilds contains info about only one attachment. I have inserted 2 images and 2 videos, but $mchilds array is containing info of first one only.
When I checked the database and run this query in database "select * from wplr_posts where post_parent='111'" then I found that other 3 attachments have value "revision" for "post_type" column.
If I changed value of "post_type" column manually to "attachment" then in front end I will get info about all attachments in $mchilds array.
I have checked this with 2 themes present in wordpress, I requested my brother also to check this and he also informed me same.
So, I have a request, Please consider this issue.
Thanks for your time.
Regards
Nidhi
Change History (5)
#3
@
11 years ago
Could not replicate either. My attachments remained attachments. The only posts rows that became revision were the post auto-save rows. I have no media rows that are post_type revision. It should not happen AFAICT.
I couldn't replicate the issue, instead of using
get_the_id()
( as it would have fetched my all posts, not inside loop ), I used the actual post id, and it works fine.