Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $media_query = new WP_Query(
- array(
- 'post_type' => 'attachment',
- 'post_status' => 'inherit',
- 'post_mime_type' =>'image',
- 'posts_per_page' => 6,
- 'orderby' => 'rand'
- )
- );
- $list = array();
- foreach ($media_query->posts as $post) {
- $list[] = wp_get_attachment_url($post->ID);
- }
- $html .= '<div class="gallery">';
- foreach($list as $image) {
- $html .= '<img src="' . $image . '"/>';
- }
- $html .= '</div>';
- echo $html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement