Advertisement
alchymyth

custom field thumbs / featured images

Mar 26th, 2011
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. ORIGINAL FROM REVOLUTION LIVESTYLE
  2.  
  3.                 <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
  4.                     <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
  5.                 <?php else: ?>
  6.                     <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
  7.                 <?php endif; ?>            
  8.  
  9.  
  10. EDITED VERSION
  11.  
  12.                 <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
  13.                     <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
  14.  
  15. <?php elseif(get_the_post_thumbnail($post->ID)) : ?>
  16.                     <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
  17.  
  18.                 <?php else: ?>
  19.                     <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
  20.                 <?php endif; ?>    
  21.  
  22. THAT IS THE GENERAL IDEA:
  23. a: check for the custom field images - if there - use theme (old posts);
  24. b: check for featured images - if there - use them (new posts);
  25. c: show default;
  26.  
  27. similar for the 'hpbottom' ones;
  28.  
  29. you probably need to adapt this to your edits so far;
  30. and you probably need to fill a few parameter into the thumbnail codes:
  31.  
  32. http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
  33. http://codex.wordpress.org/Function_Reference/the_post_thumbnail
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement