mothmenace
Member
Posted 2 years ago #
Hello, I'm using get_children to retrieve all images from my site like
$images = get_children( 'post_type=attachment&post_mime_type=image&numberposts=-1&order=ASC&orderby=menu_order&post_parent=' )
This returns ALL images, not just published ones. I'm not 100% sure what is happening but it states here get_children sets the post_status param to 'inherit' as it presumes to be used with a defined parent, however I don't want to define a parent, just get all images are from published posts.
Any idea how to do that? Seems like a simple task.
ZaneMatthew
Member
Posted 1 year ago #
I'm having the same trouble, i tried:
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_status=publish' );
but setting post_status=publish returns nothing, going to turn on error reporting.
longtailrider
Member
Posted 1 year ago #
Same issue pulling audio:
$audios =& get_children( 'post_type=attachment&post_mime_type=audio/mpeg&post_parent=null' );
Works, but
$audios =& get_children( 'post_type=attachment&post_mime_type=audio/mpeg&post_parent=null&post_status=publish');
returns nothing :(