Fatal Error When Using has_post_image() and the_post_image()

Posted in Wordpress Development on 5 January 2010 3 comments

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 on 5 January 2010 • 7,498 visits 3 comments
Tags :


or Subscribe to specific category only :




  - 3 Comments


daniel says:

Very usefull, thanks for this post.

Jessica says:

Super-Duper web site! I’m loving this!! Will come back once more – getting you rss feeds as well, Thanks.

pomoc prawna says:

Das war wie ein hilfreicher Artikel! Ich bin gerade erst mit meinem Blog und ich hoffe, es wird so gut wie Ihre. Grüße!

Leave a Reply

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

Previous Post
«
Next Post
»