Advertisement
salvatorifabio

gallery_media

Feb 26th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2. $media_query = new WP_Query(
  3. array(
  4. 'post_type' => 'attachment',
  5. 'post_status' => 'inherit',
  6. 'post_mime_type' =>'image',
  7. 'posts_per_page' => 6,
  8. 'orderby' => 'rand'
  9. )
  10. );
  11. $list = array();
  12. foreach ($media_query->posts as $post) {
  13. $list[] = wp_get_attachment_url($post->ID);
  14. }
  15. $html .= '<div class="gallery">';
  16.  
  17. foreach($list as $image) {
  18.  
  19. $html .= '<img src="' . $image . '"/>';
  20.  
  21. }
  22.  
  23. $html .= '</div>';
  24. echo $html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement