Advertisement
Guest User

content-home.php hover title

a guest
Jun 25th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. * @package Spun
  4. * @since Spun 1.0
  5. */
  6.  
  7. /*
  8. * Get the post thumbnail; if one does not exist, try to get the first attached image.
  9. * If no images exist, let's print the post title instead.
  10. */
  11.  
  12.  
  13. global $post;
  14. $postclass = '';
  15.  
  16. if ( '' != get_the_post_thumbnail() ) {
  17. $thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail', array( 'title' => esc_attr( get_the_title() ) ) );
  18.  
  19. }
  20. else {
  21. $args = array(
  22. 'post_type' => 'attachment',
  23. 'numberposts' => 1,
  24. 'post_status' => null,
  25. 'post_mime_type' => 'image',
  26. 'post_parent' => $post->ID,
  27. );
  28.  
  29. $first_attachment = get_children( $args );
  30.  
  31. if ( $first_attachment ) {
  32. foreach ( $first_attachment as $attachment ) {
  33. $thumb = wp_get_attachment_image( $attachment->ID, 'post-thumbnail', false, array( 'title' => esc_attr( get_the_title() ) ) );
  34. }
  35. }
  36.  
  37. else {
  38.  
  39. $postclass = 'no-thumbnail';
  40.  
  41. }
  42.  
  43. }
  44. ?>
  45.  
  46. <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
  47. <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  48. <?php echo $thumb; ?>
  49. <span class="hometitle">
  50. <?php the_title(); ?>
  51. </span>
  52. </a>
  53. </article><!-- #post-<?php the_ID(); ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement