Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. global $post;
  2. $id = $post->ID;
  3. $post = get_post($post);
  4. $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=DESC&post_parent='.$post->post_parent);
  5.  
  6. $galry = get_post_gallery( 1234, false );
  7. $images = [];
  8. if ( $galry && isset( $galry['ids'] ) ) {
  9. $ids = wp_parse_id_list( $galry['ids'] );
  10. $images = get_posts( [
  11. 'post__in' => $ids,
  12. 'post_type' => 'attachment',
  13. ] );
  14. echo 'Number of images in gallery #1:<br>';
  15. echo count( $images ) . '<br>';
  16. }
  17.  
  18. $galrys = get_post_galleries( 1234, false );
  19. foreach ( $galrys as $i => $galry ) {
  20. $ids = wp_parse_id_list( $galry['ids'] );
  21. $images = get_posts( [
  22. 'post__in' => $ids,
  23. 'post_type' => 'attachment',
  24. ] );
  25. echo 'Number of images in gallery #' . ( $i + 1 ) . ':<br>';
  26. echo count( $images ) . '<br>';
  27. }
Add Comment
Please, Sign In to add comment