Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14318 reviews 1707 hosting providers

Questions & Answers

WordPress get_children() not working with posts that are not standard types

Feb 14, 2013 by SunFun
Hello there,
 when I try to get attachments of a specific post with a post format that is not standard I get an empty array. However when I use the same exact code with standard post types, it works just right returns all the right attachments.
This is the code I am using  inside the loop:
$children = get_children(array(
      'post_parent' => $post->Cus_ID,
      'post_type' => 'myattachment'

If anyone can help me out, I would be greatful.
Thanks and regards,

1 Answer

0 votes
Feb 14, 2013 by expert
I think your code is fine and your problem is not there. Make sure that your image is attached to the post itself. Go to edit  post, and click on the  "Add Media" option and select  "Uploaded to this post", and  the image should appear here