Fatal Error When Using has_post_image() and the_post_image()

Posted in Wordpress Tips on 5 January 2010 1 comment

If you followed guides for the new post thumbnail feature before Wordpress 2.9 is out, they might tell you to paste this codes (or similar) into The Loop.

<?php if ( has_post_image() ) { ?>
	<a href="<?php the_permalink(); ?>"><?php the_post_image( array( 125, 125 ), array( 'class' => 'alignleft' ) ); ?></a>
<?php } ?>

However, the function names above were based on wordpress 2.9 RC1. The functions names actually changed when Wordpress 2.9 is out.

  • has_post_image() -> has_post_thumbnail()
  • the_post_image() -> the_post_thumbnail()

So the codes you need to use is:

<?php if ( has_post_thumbnail() ) { ?>
	<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array( 125, 125 ), array( 'class' => 'alignleft' ) ); ?></a>
<?php } ?>

That’s it.

Posted by zen   @   5 January 2010 1 comment
Tags :


  - 1 Comments


daniel says:

Very usefull, thanks for this post.

Leave a Reply

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Please wrap all source codes with [code][/code] tags. Powered by Source Codes in Comments
Previous Post
« Cloude Wordpress Theme – My First Free Theme in 2010
Next Post
Usix Wordpress Theme – Free Premium Purple Theme »