get_posts fixes from DD32 and filosofo. see #6772

git-svn-id: http://svn.automattic.com/wordpress/trunk@7892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-05-05 15:46:32 +00:00
parent 26529c1423
commit 3d5a874774
2 changed files with 7 additions and 4 deletions

View File

@ -349,7 +349,8 @@ function gallery_shortcode($attr) {
} }
extract(shortcode_atts(array( extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC', 'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID, 'id' => $post->ID,
'itemtag' => 'dl', 'itemtag' => 'dl',
'icontag' => 'dt', 'icontag' => 'dt',
@ -359,7 +360,7 @@ function gallery_shortcode($attr) {
), $attr)); ), $attr));
$id = intval($id); $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) ) if ( empty($attachments) )
return ''; return '';
@ -433,7 +434,7 @@ function next_image_link() {
function adjacent_image_link($prev = true) { function adjacent_image_link($prev = true) {
global $post; global $post;
$post = get_post($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 ) foreach ( $attachments as $k => $attachment )
if ( $attachment->ID == $post->ID ) if ( $attachment->ID == $post->ID )

View File

@ -408,10 +408,12 @@ function get_posts($args = null) {
'order' => 'DESC', 'include' => '', 'order' => 'DESC', 'include' => '',
'exclude' => '', 'meta_key' => '', 'exclude' => '', 'meta_key' => '',
'meta_value' =>'', 'post_type' => 'post', 'meta_value' =>'', 'post_type' => 'post',
'post_status' => 'publish', 'post_parent' => 0 'post_parent' => 0
); );
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
if ( empty( $r['post_status'] ) )
$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
if ( ! empty($r['numberposts']) ) if ( ! empty($r['numberposts']) )
$r['posts_per_page'] = $r['numberposts']; $r['posts_per_page'] = $r['numberposts'];
if ( ! empty($r['category']) ) if ( ! empty($r['category']) )