+44 (791) 5698 086

[Solved] Fatal error: Call to undefined function the_post_thumbnail() in . . .

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Who are we?

Nabtron team includes web, desktop software and mobile apps developers along with SEO professionals.

We are available 24 hours, 7 days a week. Contact us now for anything you need!

Join our mailing list

Lets become friend :) What's your name & email?