Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

WordPress Attached Thumbnails

By: a guest on Jan 31st, 2014  |  syntax: PHP  |  size: 0.58 KB  |  views: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. add_shortcode("contest-thumbnails", "show_all_thumbs");
  2.  
  3. function show_all_thumbs() {
  4.     global $post;
  5.     $post = get_post($post);
  6.  
  7.         /* image code */
  8.         remove_all_filters('posts_orderby');
  9.         $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=rand&post_parent='.$post->ID);
  10.         if($images){
  11.         foreach( $images as $imageID => $imagePost ){
  12.                
  13.         unset($the_b_img);
  14.         $the_b_img = wp_get_attachment_image($imageID, 'thumbnail', false);
  15.         $thumblist .= '<a href="'.get_attachment_link($imageID).'">'.$the_b_img.'</a>';
  16.        
  17.         }
  18.         }
  19.         return $thumblist;
  20.         }