• I am using the 2010 theme. I am working locally on MAMP, and created my own child (won’t the medical community be proud.) Anyway…I am trying to implement a nifty thumbnail–one that changes color as you hover over it–on the main page. The code was written by this brilliant fellow: http://bavotasan.com/2011/create-black-white-thumbnail-wordpress/

    So, first, I wrote his two big light-blue boxed code in the functions file. Then I added the fade code into the css file. I wrote a test post, and uploaded an image, and set it as the “featured post”, but did NOT insert into the post. So far, so good–the uploads folder shows the magically created black and white images. It’s that loop business that I can’t master. He writes: Once you’ve added the above code, you can use get_post_thumbnail() within your WordPress loop to display the two images for the effect:

    if(function_exists('has_post_thumbnail') && has_post_thumbnail()) {
    	echo '<a href="'.get_permalink().'" class="fade-image">';
    	the_post_thumbnail('thumbnail-bw', array('class'=>'fade-image-a'));
    	the_post_thumbnail('thumbnail', array('class'=>'fade-image-b'));
    	echo '</a>';
    }

    I feel daft, but I don’t understand his instruction. What I did was type:
    <?php get_post_thumbnail(); ?> into the loop-index file, and this into the functions file: `function get_post_thumbnail(){echo ‘<a href=”‘.get_permalink().'” class=”fade-image”>’;
    the_post_thumbnail(‘thumbnail-bw’, array(‘class’=>’fade-image-a’));
    the_post_thumbnail(‘thumbnail’, array(‘class’=>’fade-image-b’));
    echo ‘</a>’;}`

    Needless to say, only a color thumbnail appears on the main page (good) and NO image appears on the post page (good), but that color thumbnail on the main page won’t change color.

    Can someone help? Thank you.

  • The topic ‘Functions, loops, and thumbnails’ is closed to new replies.