Revision: 54254
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 17, 2011 02:36 by adambundy
Initial Code
function pippin_gallery_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'size' => '' ), $atts ) ); $image_size = 'medium'; if($size =! '') { $image_size = $size; } $images = get_children(array( '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');
Initial URL
Initial Description
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
Initial Title
Wordpress Image Gallery Short Code Using Post Attachments
Initial Tags
php, image, wordpress
Initial Language
PHP