Created
June 20, 2016 14:25
-
-
Save celticwebdesign/97cc19527e7c35811ea2fb2438d72ee3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// If needed to get a specific category | |
// echo "<pre>"; | |
// var_dump($wp_query->query_vars); | |
// echo "</pre>"; | |
// echo $wp_query->query_vars['gallery-category']; | |
$args = array( | |
'post_type' => 'gallery', | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'orderby' => 'rand' | |
); | |
// The query | |
$child_query = new WP_Query($args); | |
// The loop | |
if( $child_query->have_posts() ) : while ( $child_query->have_posts() ) : $child_query->the_post(); | |
$image_attributes = wp_get_attachment_image_src( get_field('gallery_photo'), 'medium' ); | |
$image_attributes_l = wp_get_attachment_image_src( get_field('gallery_photo'), 'large' ); | |
$alt_text = get_post_meta( get_field('gallery_photo'), '_wp_attachment_image_alt', true); | |
echo "<a href='".$image_attributes_l[0]."' rel='gallery1' class='fancy grid-item'> | |
<img src='".$image_attributes[0]."' alt='".$alt_text."' width='100%' height='100%'> | |
</a>"; | |
endwhile; endif; | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment