Home / posts / Custom post thumbnails
  • How to Custom post thumbnails

    no thumbnail sorry: Custom post thumbnails

    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.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?php
             $postimageurl = get_post_meta($post->ID, 'post-img', true);
         if ($postimageurl) {
    ?>
    <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="<?php the_title(); ?>" width="210" height="210" /></a>
    <?php } else { ?>
    <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>
    <?php } ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    template, the_title, the_permalink, bloginfo, get_post, get_post_meta, wp,