/ Published in: PHP
UPDATE: might be easier or faster to use this now (also courtesy Pippin): http://pippinsplugins.com/get-all-attached-media/
**courtesy Pippin Williamson (http://pippinsplugins.com/image-gallery-short-code-using-post-attachments/)
use shortcode [photo_gallery] to display the gallery
**courtesy Pippin Williamson (http://pippinsplugins.com/image-gallery-short-code-using-post-attachments/)
use shortcode [photo_gallery] to display the gallery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function pippin_gallery_shortcode( $atts, $content = null ) { 'size' => '' ), $atts ) ); $image_size = 'medium'; if($size =! '') { $image_size = $size; } 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'orderly' => 'menu_order', //'exclude' => get_post_thumbnail_id(), -- uncomment to exclude post thumbnail 'post_mime_type' => 'image', ) ); if($images) { $gallery = '<ul class="gallery clearfix">'; foreach( $images as $image ) { $gallery .= '<li>'; $gallery .= '<a href="' . wp_get_attachment_url($image->ID) . '" rel="shadowbox">'; $gallery .= wp_get_attachment_image($image->ID, $image_size); $gallery .= '</a>'; $gallery .= '</li>'; } $gallery .= '</ul>'; return $gallery; } } add_shortcode('photo_gallery', 'pippin_gallery_shortcode');