Title: throbthrobnet's Replies | WordPress.org

---

# throbthrobnet

  [  ](https://wordpress.org/support/users/throbthrobnet/)

 *   [Profile](https://wordpress.org/support/users/throbthrobnet/)
 *   [Topics Started](https://wordpress.org/support/users/throbthrobnet/topics/)
 *   [Replies Created](https://wordpress.org/support/users/throbthrobnet/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/throbthrobnet/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/throbthrobnet/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/throbthrobnet/engagements/)
 *   [Favorites](https://wordpress.org/support/users/throbthrobnet/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [wp_query and getting specific images from the system](https://wordpress.org/support/topic/wp_query-and-getting-specific-images-from-the-system/)
 *  Thread Starter [throbthrobnet](https://wordpress.org/support/users/throbthrobnet/)
 * (@throbthrobnet)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/wp_query-and-getting-specific-images-from-the-system/#post-1117374)
 * i figured it out and recoded the entire thing:
 *     ```
       function get_slideshow_images() {
       	global $wpdb;
   
       	$_query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts AS posts
       		WHERE posts.post_type = 'attachment'
       		AND posts.post_content = 'slideshow'
       		AND posts.post_mime_type IN ('image/jpeg','image/gif','image/jpg','image/png')
       		ORDER BY ID ASC
       		");
   
       	$_result = $wpdb->get_results($_query);
   
       	if (count($_result > 0)) {
       		print "<div id=\"featured_container\">\n";
       		foreach ($_result as $_post) {
       			print "\t\t<img src=\"".wp_get_attachment_url($_post->ID)."\">\n";
       		}
       		print "\t\t</div>\n";
       	}
   
       }
       ?>
       ```
   
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [wp_query and getting specific images from the system](https://wordpress.org/support/topic/wp_query-and-getting-specific-images-from-the-system/)
 *  Thread Starter [throbthrobnet](https://wordpress.org/support/users/throbthrobnet/)
 * (@throbthrobnet)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/wp_query-and-getting-specific-images-from-the-system/#post-1117256)
 * let me try to format the code a bit better here…
 *     ```
       function getImagesForSlideshow($_max = 5, $order = 'latest')
       {
   
           if ($order == 'random') {
               $r = new WP_Query("showposts=$_max&what_to_show=posts&post_status=inherit&post_type=attachment&orderby=rand&post_mime_type=image/jpeg,image/gif,image/jpg,image/png&post_content=slideshow");
           } else {
               $r = new WP_Query("showposts=$_max&what_to_show=posts&post_status=inherit&post_type=attachment&orderby=menu_order ASC, ID ASC&post_mime_type=image/jpeg,image/gif,image/jpg,image/png&post_content=slideshow");
           }
   
           if ($r->have_posts()) {
   
               echo "<div id=\"featured_container\">\n";
               while ($r->have_posts()) : $r->the_post();
   
       		#echo apply_filters('the_content', $np->post_content);
       //		$gimme = the_title();
       		//print "\t\t<img src=\"".wp_get_attachment_url(get_the_ID())."\" title=\"".$gimme."\"/>\n";
   
       			print "\t\t<img src=\"".wp_get_attachment_url(get_the_ID())."\"/>\n";
   
       		#print "<!-- " . get_the_content() ."-->\n";
               endwhile;
       		echo "\t\t</div>\n";
           }
   
           return $_retval;
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)