Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

[spun] content-home.php

By: a guest on Aug 20th, 2013  |  syntax: PHP  |  size: 1.34 KB  |  views: 161  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. global $post;
  13. $postclass = '';
  14. $extra_word = types_render_field( "extra-word", array("raw"=>"true") );
  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. else {
  20.         $args = array(
  21.                                 'post_type' => 'attachment',
  22.                                 'numberposts' => 1,
  23.                                 'post_status' => null,
  24.                                 'post_mime_type' => 'image',
  25.                                 'post_parent' => $post->ID,
  26.                         );
  27.  
  28.         $first_attachment = get_children( $args );
  29.  
  30.         if ( $first_attachment ) {
  31.                 foreach ( $first_attachment as $attachment ) {
  32.                         $thumb = wp_get_attachment_image( $attachment->ID, 'post-thumbnail', false, array( 'title' => esc_attr( get_the_title() ) ) );
  33.                 }
  34.         }
  35.         else {
  36.                 $thumb = '<span class="no-thumbnail">' . get_the_title() . '</span>';
  37.                 $postclass = 'no-thumbnail';
  38.         }
  39. }
  40. ?>
  41.  
  42. <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
  43.         <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo $thumb; ?></a>
  44.         <p>
  45.                 <?php echo $extra_word; ?>
  46.         </p>
  47. </article><!-- #post-<?php the_ID(); ?> -->