dragunoff

[WP] TimThumb images attached to a post

May 7th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1.  
  2. function get_all_image_from_post()
  3.  
  4. {
  5.  
  6.     global $post;
  7.  
  8.  
  9.  
  10.     $imagenes = get_posts(array('post_parent' => $post->ID,
  11.  
  12.                                 'post_mime_type' => 'image',
  13.  
  14.                                 'post_type' => 'attachment',
  15.  
  16.                                 'exclude' => array(get_post_thumbnail_id()),
  17.  
  18.                                 'numberposts' => -1
  19.  
  20.                                 )
  21.  
  22.                             );
  23.  
  24.         $listado_imagenes = array();
  25.  
  26.         foreach ($imagenes as $imagen){
  27.  
  28.             $image_src = wp_get_attachment_image_src($imagen, 'full');
  29.  
  30.             $listado_imagenes[] = $imagen[0];
  31.  
  32.         }
  33.  
  34.         return $listado_imagenes;
  35.  
  36. }
  37.  
  38.  
  39. $imagenes = get_all_image_from_post();
  40.  
  41. foreach ($imagenes as $imagen): ?>
  42.  
  43. <img src="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php echo $imagen; ?>&amp;h=260&amp;w=260" class="index" alt="<?php the_title(); ?>" title="<?php the_title(); ?>, <?php comments_number('No comments','One comment','% comments'); ?>" />
  44.  
  45.  
  46.  
  47. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment