Display thumbnail from custom post type in template file

My single.php has a function for determining which template to use based on the custom post type – it will grab the corresponding template file and display it. I managed to get the contents of the post and everything I need but I am having difficulty displaying the_post_thumbnail() – nothing shows. I had a similar problem with the title and I had to use single_post_title() instead of the_title(). I can’t figure out the issue around the thumbnail as I tried every function to display it. It does, however, display the thumbnail if the location of the code is in the single.php and no template file.

Note: I do have the add_theme_support( ‘post-thumbnails’ ); in my functions and the featured image is visible on the posts edit page.

Read more here:: Display thumbnail from custom post type in template file

Leave a Reply

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