Title: How to implement in theme
Last modified: August 22, 2016

---

# How to implement in theme

 *  Resolved [just_ducky](https://wordpress.org/support/users/just_ducky/)
 * (@just_ducky)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/)
 * I am having trouble implementing this in my theme. I verified that the plugin
   is generating an image from my pdf in the media gallery.
 * I tried adding
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?
   >
 * in my theme in the proper place, but nothing displays. Do you have any ideas?
 * [https://wordpress.org/plugins/pdf-thumbnails/](https://wordpress.org/plugins/pdf-thumbnails/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [stianlik](https://wordpress.org/support/users/stianlik/)
 * (@stianlik)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442621)
 * The thumbnail is stored on the PDF attachment, is it possible that you are trying
   to get a thumbnail for a normal post?
 * An easy way to test if thumbnails are working is to add the code you posted to
   single-attachment.php and open a PDF-attachment to verify that thumbnail is shown.
 * You can also use `get_the_post_thumbnail($pdf_attachment_id)` if you know the
   attachment ID.
 * If this does not work, I need some more information to go on, viewing the entire
   template file in would be helpful.
 *  [provdes](https://wordpress.org/support/users/provdes/)
 * (@provdes)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442632)
 * I’m also having trouble bringing this into my template file.
 * The thumbnail is created and is in the media library, but I cannot get it to 
   show. I can’t see any reference anywhere to a link between the attachment file(
   the PDF) and the thumbnail that has been created.
 * I have tried the following code in my template file: I am using the Advanced 
   Custom Fields plugin, and my custom field for the PDF is called ‘file’ hence 
   the `get_field('file');`
 *     ```
       <?php $attachment_id = get_field('file');
       $filethumb = get_post_thumbnail_id( $attachment_id ); ?>
   
       <div class="thumb"><?php the_post_thumbnail( $filethumb ); ?></div>
       ```
   
 * I have lots of other elements on the template using the `$attachment_id` and 
   it is returning the id of the PDF file (which i’m using for file names, file 
   sizes etc)
 * I’m not sure how to go about testing it as you have mentioned above. My theme
   does not have a single-attachment.php file…
 * You mention that it works as the featured image, which I have a meta box for 
   on my edit page – should the thumbnail be being displayed here?
 * This looks to be a super sweet plugin, worthy of many stars : )
 *  Plugin Author [stianlik](https://wordpress.org/support/users/stianlik/)
 * (@stianlik)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442633)
 * A subtle detail of `the_post_thumbnail()` is that it only works with current 
   post in _The Loop_, you cannot pass an ID to that function. Your code should 
   work if you replace `the_post_thumbnail` with `echo get_the_post_thumbnail`:
 *     ```
       <?php echo get_the_post_thumbnail($filethumb); ?>
       ```
   
 *  [provdes](https://wordpress.org/support/users/provdes/)
 * (@provdes)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442634)
 * Thanks, but unfortunately still nothing displaying for me if I use `get_the_post_thumbnail()`
 * I have got it working through using this method:
 *     ```
       <?php $attachment_id = get_field('file');
       $filethumb = wp_get_attachment_image_src( get_post_thumbnail_id( $attachment_id ), medium ); ?>
   
       <div class="thumb"><img src="<?php echo $filethumb[0] ?>"/></div>
       ```
   
 * `wp_get_attachment_image_src` got me everything I needed 🙂
 * Now a very happy chap!
 *  Plugin Author [stianlik](https://wordpress.org/support/users/stianlik/)
 * (@stianlik)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442635)
 * Great! Thank you for posting the solution, and a great review.
 * Actually, `get_the_post_thumbnail($id)` calls `wp_get_attachment_image_src($id)`
   internally, so you should be able to make it work with the code below. In my 
   earlier comment, `$filethumb` should have been `$attachment_id`, sorry for the
   blunder.
 *     ```
       <?php $attachment_id = get_field('file'); ?>
       <div class="thumb">
           <?php echo get_the_post_thumbnail($attachment_id, 'medium'); ?>
       </div>
       ```
   
 * That would make your code slightly easier to read.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘How to implement in theme’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/pdf-thumbnails.svg)
 * [PDF Thumbnails](https://wordpress.org/plugins/pdf-thumbnails/)
 * [Support Threads](https://wordpress.org/support/plugin/pdf-thumbnails/)
 * [Active Topics](https://wordpress.org/support/plugin/pdf-thumbnails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pdf-thumbnails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pdf-thumbnails/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [stianlik](https://wordpress.org/support/users/stianlik/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/how-to-implement-in-theme/#post-5442635)
 * Status: resolved