Created
March 13, 2015 15:35
-
-
Save priyabratary/ce80b39ea9fc4faa6ed9 to your computer and use it in GitHub Desktop.
Gallery shortcode
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
//Gallery shortcode | |
function gallerys_shortcode($atts, $content){ | |
extract( shortcode_atts (array( // a few default values | |
) | |
, $atts)); | |
$q = new WP_Query( | |
array('posts_per_page' => 3, 'post_type' => 'gallery-items', 'order' => 'ASC', ) | |
); | |
$list = ' <div class="row">'; | |
while($q->have_posts()) : $q->the_post(); | |
$saved_post_id = get_the_ID(); | |
$feat_image = wp_get_attachment_url( get_post_thumbnail_id( $saved_post_id ) ); | |
$list .= ' | |
<div class="col-xs-12 col-sm-4 col-md-4"> | |
<figure class="thumbnail text-center"> | |
<a rel="lightbox[group]" href="'.$feat_image.'"> | |
'.get_the_post_thumbnail( get_the_ID(), 'gallery-image' ).' | |
<img src="'. get_template_directory_uri() .'/images/g-hover.png" class="round" alt=""/> | |
</a> | |
<img src="'. get_template_directory_uri() .'/images/g-shadow.png" alt=""/> | |
</figure> | |
</div>'; | |
endwhile; | |
$list.= '</div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('gallery','gallerys_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment