Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $post;
- $id = $post->ID;
- $post = get_post($post);
- $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=DESC&post_parent='.$post->post_parent);
- $galry = get_post_gallery( 1234, false );
- $images = [];
- if ( $galry && isset( $galry['ids'] ) ) {
- $ids = wp_parse_id_list( $galry['ids'] );
- $images = get_posts( [
- 'post__in' => $ids,
- 'post_type' => 'attachment',
- ] );
- echo 'Number of images in gallery #1:<br>';
- echo count( $images ) . '<br>';
- }
- $galrys = get_post_galleries( 1234, false );
- foreach ( $galrys as $i => $galry ) {
- $ids = wp_parse_id_list( $galry['ids'] );
- $images = get_posts( [
- 'post__in' => $ids,
- 'post_type' => 'attachment',
- ] );
- echo 'Number of images in gallery #' . ( $i + 1 ) . ':<br>';
- echo count( $images ) . '<br>';
- }
Add Comment
Please, Sign In to add comment