[wp-hackers] Is there no get_post_attachments() function(ality)?

Mike Schinkel mikeschinkel at newclarity.net
Wed Sep 15 02:28:44 UTC 2010


Hey Austin, Spencer, Paul and Michael:

Wow, thanks for the rapid response all.  

Clearly I just had a mental block on that one.  I did a regex search across the codebase using "SELECT.*?WHERE.*?post_parent" and nothing came up.  I missed get_children() because it delegates to get_posts() and I don't know why I didn't thing about querying that way. It's so obvious now, doh!

Thanks again.

-Mike

On Sep 14, 2010, at 9:50 PM, Michael Pretty wrote:

> This is probably your best bet.
> 
> get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
> 
> On 9/14/10 9:48 PM, Austin Matzko wrote:
>> On Tue, Sep 14, 2010 at 8:42 PM, Mike Schinkel
>> <mikeschinkel at newclarity.net>  wrote:
>>> I just had a need to load a list of attached photos for a post but try as I might I couldn't find a function to retrieve them, a function I would expect to be called something like get_post_attachments().
>>> 
>>> I'm emailing to see if I overlooked something in core; did I miss a function to do what I was looking for?
>> How about get_children()?
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list