php - How to count image of gallery in wordpress gallery shortcode -
i want display total of item in wordpress gallery each post. code this, not work. post display wrong number of item in gallery.
$args = array(     'order' => 'asc',     'post_mime_type' => 'image',     'post_parent' => $post->id,     'post_status' => null,     'post_type' => 'attachment', );  $pattern = get_shortcode_regex(); preg_match('/'.$pattern.'/s', $post->post_content, $matches); if (is_array($matches) && $matches[2] == 'gallery') {     //     preg_match('/\[ gallery ids=\"(.*?)\"]/',$matches[0],$ids);      if (is_array($ids) && $ids[1] ) {         $photos = explode(',',$ids[1]);     } else {         $photos = get_children( $args );     }     $total_images = count($photos); }       
 
  
Comments
Post a Comment