WP 3.5 and Galleries – how to count images?

This works: $images = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘numberposts’ => 999 )); if ( $images ) { $total_images = count( $images ); } The variable $total_images will hold the count of images in your gallery.

How to show description under an inserted image?

This is actually quite easy: You just hijack the short code handler for image captions, grab the post_content (the image description) and set its content as a value for the attribute caption. Then you call the original shortcode handler. The following example requires the shortcode attribute desc set to 1 to make the magic work: … Read more

How do i add class=”fancybox” to the default gallery?

You can use javascript/jquery to solve this. When you insert a gallery in a wordpress posts, the whole gallery is wrapped by a div with id like “gallery-1” but also a class that’s always “gallery”. Also, every item is surrounded by two other “dl” and “dt”, with class “gallery-item” and “gallery-icon” respectively. So, you can … Read more

Gallery Inside One Post

These functions will help: //function to get next or previous keys in an array function array_navigate($array, $key){ $keys = array_keys($array); $index = array_flip($keys); $return = array(); $return[‘prev’] = (isset($keys[$index[$key]-1])) ? $keys[$index[$key]-1] : end($keys); $return[‘next’] = (isset($keys[$index[$key]+1])) ? $keys[$index[$key]+1] : current($keys); return $return; } function previous_attachment_ID($att_post){ //get the attachments which share the same post parent $images … Read more