From 3d5a874774006b8c80d62065d9c3b26c82abac9d Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 5 May 2008 15:46:32 +0000 Subject: [PATCH] get_posts fixes from DD32 and filosofo. see #6772 git-svn-id: http://svn.automattic.com/wordpress/trunk@7892 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 7 ++++--- wp-includes/post.php | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 5a5dc8701..e25fd3318 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -349,7 +349,8 @@ function gallery_shortcode($attr) { } extract(shortcode_atts(array( - 'orderby' => 'menu_order ASC, ID ASC', + 'order' => 'ASC', + 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', @@ -359,7 +360,7 @@ function gallery_shortcode($attr) { ), $attr)); $id = intval($id); - $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}"); + $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); if ( empty($attachments) ) return ''; @@ -433,7 +434,7 @@ function next_image_link() { function adjacent_image_link($prev = true) { global $post; $post = get_post($post); - $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC")); + $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )); foreach ( $attachments as $k => $attachment ) if ( $attachment->ID == $post->ID ) diff --git a/wp-includes/post.php b/wp-includes/post.php index db95c7809..63c9ff48a 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -408,10 +408,12 @@ function get_posts($args = null) { 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', - 'post_status' => 'publish', 'post_parent' => 0 + 'post_parent' => 0 ); $r = wp_parse_args( $args, $defaults ); + if ( empty( $r['post_status'] ) ) + $r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish'; if ( ! empty($r['numberposts']) ) $r['posts_per_page'] = $r['numberposts']; if ( ! empty($r['category']) )