Advertisement
Guest User

Untitled

a guest
Jun 4th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php /*
  2. Related Thumbnails
  3. Author: John Godley
  4. */
  5. ?>
  6.  
  7. <?php if ($related_query->have_posts()):?>
  8.  
  9. <ol class="related-posts">
  10. <?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
  11.  
  12. <li>
  13. <?php
  14. $img = '';
  15. if ( has_post_thumbnail() ) {
  16. $img = get_the_post_thumbnail( $post->ID, 'related-thumbnail', array( 'title' => $title, 'alt' => $title ) );
  17. }
  18. else {
  19. $attachments = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1 ) );
  20.  
  21. if ( count( $attachments ) > 0 ) {
  22. $img = array_shift( $attachments );
  23. $img = wp_get_attachment_image( $img->ID, 'related-thumbnail', true );
  24. }
  25. }
  26.  
  27. $extra_class = '';
  28. if ( $img == '' ) {
  29. $img = wp_html_excerpt( get_the_excerpt(), 40 );
  30. $extra_class = ' related-thumb-text';
  31. }
  32. ?>
  33. <div class="related-post">
  34. <div class="related-thumb<?php echo $extra_class; ?>">
  35. <a href="<?php the_permalink() ?>" rel="bookmark">
  36. <?php echo $img; ?>
  37. </a>
  38. </div>
  39.  
  40. <div class="related-title">
  41. <a href="<?php the_permalink() ?>" rel="bookmark">
  42. <?php the_title(); ?>
  43. </a>
  44. </div>
  45. </div>
  46. </li>
  47.  
  48. <?php endwhile; ?>
  49. </ol>
  50. <div style="clear: both"></div>
  51.  
  52. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement