Advertisement
salmancreation

How to Custom post thumbnails

Aug 5th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. Adding this PHP code to your wordpress theme will allow you to define a post thumbnail. Create a custom field called post-img and add a URL to your image.
  2. <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).')" class="single_slider">
  3.  
  4. <?php
  5.          $postimageurl = get_post_meta($post->ID, 'post-img', true);
  6.      if ($postimageurl) {
  7. ?>
  8.  
  9. <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="<?php the_title(); ?>" width="210" height="210" /></a>
  10.  
  11. <?php } else { ?>
  12.  
  13. <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php bloginfo('template_url'); ?>/images/wpbeginner.gif" alt="<?php the_title(); ?>" width="210" height="210" /></a>
  14.  
  15. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement