Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to build a photostream that sorts the loop by the modified date of a post type. The goal being that as a post is updated with new attachments, it gets pushed to the front of the loop. My problem is that the loop is not being ordered properly. Am I doing something wrong?

$photostream = new WP_Query( array(
    'post_type' => 'inventory',
    'orderby' => 'modified',
    'paged' => $paged,  ) );

if( $photostream->have_posts() ) { 
while( $photostream->have_posts() ){
$photostream->the_post(); 

    the_title('<span>', '</span>, ');

    $mediaargs = array( //check to see if has media
        'order'          => 'ASC',      'post_type'      => 'attachment',
        'post_parent'    => $post->ID,  'post_mime_type' => 'image',
        'post_status'    => null,       'numberposts'    => -1, );
    $attachments = get_posts($mediaargs);
        if ($attachments) { 
            echo do_shortcode('[gallery size="small" columns="8" link="file"]');
            echo '<div class="clear"></div>'; 
        }

} } wp_reset_query();  
share|improve this question
Looks ok to me. Does anything change if you remove the orderby argument? – One Trick Pony Jun 30 '11 at 0:23
@One Trick Pony nope :/ – mattrepublic Jun 30 '11 at 1:28
Have you solved this problem? – toscho Dec 27 '12 at 23:22
@toscho nope... – mattrepublic Dec 29 '12 at 16:11

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.