Today i was working on a WordPress based website which needed a custom featured posts widget to be created when I received some error.
The widget used this code to get the post thumbnail:
<?php the_post_thumbnail( array(87, 112, true) ); ?>
Let’s not go into much details of this function (you can find it in wordpress codex).
However, when I used this function and refreshed the page using widget, it gave me an error saying:
Fatal error: Call to undefined function the_post_thumbnail() in ****/******/********/*****/***** on line 13
This might seem like a nightmare at first! but relax. This is because you didn’t tell WordPress that your theme is going to use this function to display thumbnails.
To solve the issue of fatal error with the_post_thumbnail() function, simply add this code in your WordPress theme’s functions.php file:
And now this will remove the error from your WordPress blog / site while using this function.
You might also like
- Do you license your scripts before giving it to the client?
- WordPress Show image title only on attachment page (with all in one seo editing too)
- How to show specific post(s) in WordPress
- Fatal error: Cannot redeclare class FacebookApiException – Solution
- Nabthesis – Free theme for WordPress released by Nabtron