rozanchetta

Wordpress - Imagens do Post em Lista não ordenada

Sep 5th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2. /* No functions.php */
  3. // Função para galeria em lista não ordenada - uso em Slides - neste exemplo: PikaChoose
  4. function slide_image_gallery() {
  5. global $post;
  6. $limitImages = 5; /* número de imagens no slide */
  7. $args = array(
  8. 'post_type' => 'attachment',
  9. 'post_mime_type' => 'image',
  10. 'numberposts' => $limitImages + 1,
  11. 'orderby' => 'menu_order',
  12. 'order' => 'ASC',
  13. 'post_parent' => $post->ID
  14. );
  15. $images = get_posts($args);
  16. if($images) :
  17. $count = 1;
  18. foreach($images as $image) {
  19. $full_image_url = wp_get_attachment_image_src( $image->ID, 'full'); /* link para a imagem grande - útil para o fancybox */
  20. $imageCaption = $image->post_excerpt; /* legenda da imagem do post para ser usada como a Caption do Pikachoose */
  21. if($count <= $limitImages) :
  22. echo '<li><a href="' . $full_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
  23. echo wp_get_attachment_image($image->ID, 'gallery-thumbnail');
  24. echo '</a>';
  25. echo '<span>' .$imageCaption. '</span>';
  26. echo '</li>';
  27. endif;
  28. $count++;
  29. }
  30. endif;
  31. }
  32. ?>
  33.  
  34.  
  35. /* No loop, depois de <php the_content(); ?> */
  36. <div id="pikachoose">
  37. <ul id="pikame">
  38. <?php slide_image_gallery(); ?>
  39. </ul>
  40. </div>
Advertisement
Add Comment
Please, Sign In to add comment