Advertisement
Kraignos

wordpress thumbnail display custom field check

Jun 24th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Thumbnail display - custom field based.
  4.  *
  5.  * Let's say you've got a custom field with the name "show_thumb"
  6.  * You type "yes" as its value to display the thumbnail (or a default picture); any other value won't show any picture, only the content.
  7.  * Don't know so much about custom field, maybe you would prefer using a checkbox, if possible, rather than a text field...
  8.  */
  9. if( get_post_meta($post->ID, "show_thumb", true) == "yes") :
  10.     $image = get_post_meta($post->ID,"Image",true);
  11.     if ( !empty($image) ) { ?>
  12.             <img src="<?php echo $image; ?>" alt="thumbnail" style="float: left;margin:  0.9em 0.5em 0.5em 0.1em; border: 2px solid #B3B3B3; width: 150px; height: 150px;" /><?php
  13.     } else { ?>
  14.             <img src="http://*****.com/blog/wp-content/uploads/no-thumb.png" alt="default thumbnail" style="float: left; margin:  0.9em 0.5em 0.5em 0.1em; border: 2px solid #B3B3B3; width: 150px; height: 150px;" />
  15.     <?php
  16.     }
  17. endif;  ?>
  18.  
  19. <?php the_content('<span class="more-link">'.__('More…', 'plaintxtblog').'</span>') ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement