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();