SHARE
TWEET

WordPress Attached Thumbnails

a guest Jan 31st, 2014 41 Never
  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.         }
RAW Paste Data
Top