• Resolved Socke

    (@socke)


    I tried the following:

    <?php if( have_posts() ) : ?>
    
    		<?php while( have_posts() ) : the_post(); ?>
    
    			<?php get_template_part( 'loop-header' ); ?>
    
    			<?php responsive_entry_before(); ?>
    			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    				<?php responsive_entry_top(); ?>
    
    				<?php get_template_part( 'post-meta-page' ); ?>
    
    				<div class="post-entry">
    					<?php the_content( __( 'Read more ›', 'responsive' ) ); ?>
    					<?php wp_link_pages( array( 'before' => '<div class="pagination">' . __( 'Pages:', 'responsive' ), 'after' => '</div>' ) ); ?>
    				<?php $id = get_the_ID(); ?>
    				<a href="<?php echo wp_get_attachment_url($id); ?>">
        					<?php echo get_the_post_thumbnail($id); ?>
    				</a>
    			</div>
    				<!-- end of .post-entry -->

    but that does nothing. if i select attachment-page as link-target, it still shows the jpg-file ??

    https://www.ads-software.com/plugins/pdf-thumbnails/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author stianlik

    (@stianlik)

    To view the generated thumbnail for a PDF, all you need to do is:

    echo get_the_post_thumbnail($id);

    Where $id is the ID of a PDF file you uploaded after installing the plugin. For your first try, you can copy the ID shown in your address bar when editing uploaded PDF in the media manager.

    To give you more specific advice, I need some more information:

    1. Which template file is the code from (i.e. filename)?
    2. Did you upload the PDF before or after you installed “PDF Thumbnails”?
    3. What do you mean by “it still shows the jpg-file”? Which jpg do you
      see?
    Thread Starter Socke

    (@socke)

    Thanks for your fast answer.

    The file is called page.php
    I uploaded the PDF after installing your plugin
    i mean, that clicking on the thumbnail opens the generated jpg-file, not the pdf-file.

    if i try <?php echo get_the_post_thumbnail(742); ?> that does nothing.

    the thumbnails are generated correctly, i just need to get the connection between the thumbnail and the pdf, so my wife won’t have to bother with manual linking.

    Plugin Author stianlik

    (@stianlik)

    If I understand you correctly, you have set the PDF thumbnail as a featured image for a static page? The image is displaying as expected, but you need some way to get PDF attachment ID?

    In the current version it works the other way around, there is a connection from the PDF to the thumbnail. That is, if you have the ID of a PDF, you can show the thumbnail. However, it would make sense to have a bi-directional connection.

    I will publish a new version 0.0.6 shortly, with that you can get the PDF ID using post_parent:

    echo get_the_permalink(wp_get_post_parent_id($thumbnailId)));

    This will only work for PDFs that you uploaded after upgrading to version 0.0.6. If you need support for older thumbnails, you can add
    the connection manually by setting the post_parent-parameter for your existing thumbnails.

    Thread Starter Socke

    (@socke)

    the intended way would be ok, if only it would work ??

    Thread Starter Socke

    (@socke)

    after trying several ways of implenting the code, i guess i need a step by step manual or how-to. Seems i’m too stupid or too old or probably both ??

    Plugin Author stianlik

    (@stianlik)

    It should be fairly easy to make the plugin work, but it can be used in many different ways. I can probably guide you through it if you explain exactly what you are trying to do and how the solution should be used afterwards. I.e. step-by-step explanation of how your wife would use the system and the expected outcome.

    Edit:

    I’m guessing that you are trying to link to PDF-files uploaded to the current page? In that case, you can replace your attachment-code with
    the following:

    <?php foreach (get_attached_media('application/pdf') as $pdf): ?>
        <a href="<?php echo wp_get_attachment_url($pdf->ID); ?>">
            <?php echo get_the_post_thumbnail($pdf->ID); ?>
        </a>
    <?php endforeach; ?>

    This will get all PDF attachments uploaded to the current page and display a thumbnail with download link to the PDF.

    Thread Starter Socke

    (@socke)

    thanks a lot, i’ll give that one a try!

    Plugin Author stianlik

    (@stianlik)

    No problem. Haven’t heard anything in a week, so I’m marking this as resolved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘where and how to put in that magic snippet?’ is closed to new replies.