custom gallery shortcode for WordPress
function parse_gallery_shortcode($atts) {
global $post;
$output = apply_filters('post_gallery','', $atts);
extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 10,
'size' => 'property-thumb',
'link' => 'file',
'ids' => array()
), $atts));
$args = array(
'post_type' => 'attachment',
'posts_per_page' => 10,
'orderby' => $orderby
);
$images = get_posts($args);
echo '<div id="gallery-1" class="custom-gallery">';
foreach ( $images as $image ) {
$caption = $image->post_excerpt;
$description = $image->post_content;
$title = $image->post_title;
$pname = $image->post_name;
$large_img = post_permalink() . $pname . '/';
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, $size);
// render gallery here
echo '<dl class="gallery-item">';
echo '<dt class="gallery-icon">';
echo '<a title="' . $title . '" href="' . $large_img . '"><img src="' . $img[0] . '" width="' . $img[1] . '" height="' . $img[2] . '"></a>';
echo '</dt>';
echo '</dl>';
}
echo '</div>';
}