Created
June 30, 2012 19:36
-
-
Save wpsmith/3025221 to your computer and use it in GitHub Desktop.
Attachment Metadata Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_status' => 'inherit', // Default status of attachments | |
'post_type' => array( 'attachment' ), | |
'meta_key' => '_wp_attachment_metadata', | |
'meta_value' => 'FinePix J10', | |
'meta_compare' => 'LIKE', | |
); | |
$attachment_query = new WP_Query( $args ); | |
// The Title | |
printf( '<h2>%s</h2>', __( 'FinePix J10 Pictures', 'text_domain' ) ); | |
// The Loop | |
if ( $attachment_query->have_posts() ) : | |
while ( $attachment_query->have_posts() ) : $attachment_query->the_post(); | |
// Do Stuff | |
echo wp_get_attachment_image( $post->ID, 'thumbnail' ); | |
endwhile; | |
endif; | |
// Reset Post Data | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment