Skip to content

Instantly share code, notes, and snippets.

@matheusgimenez
Created March 13, 2014 02:02
Show Gist options
  • Save matheusgimenez/9520656 to your computer and use it in GitHub Desktop.
Save matheusgimenez/9520656 to your computer and use it in GitHub Desktop.
<?php
// WP_Query arguments
$args = array (
'posts_per_page' => '6',
'post_type' => 'attachment',
'meta_query' => array(
array(
'key' => 'galeriaimg',
'value' => 'sim',
),
),
);
// The Query
$attachment = new WP_Query( $args );
// The Loop
if ( $attachment->have_posts() ) {
while ( $attachment->have_posts() ) {
$img_url = wp_get_attachment_url( $attachment->ID, 'medium', false );
$img_url_full = wp_get_attachment_url( $attachment->ID, 'large', false );
echo '<a class="fancybox" href="'.$img_url_full.'">';
echo '<img src="'.$img_url.'">';
echo '</a>';
}
} else {
echo '<h1>ERRO1</h1>';
}
// Restore original Post Data
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment