• Resolved mcyzyk

    (@mcyzyk)


    This is definitely what I want to do:

    get_pdf_thumbnail_image( $pdf_id )

    But how do I get $pdf_id for the current Post?

    Mark

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mcyzyk

    (@mcyzyk)

    So, for instance, this returns 0 every time:

    $pdf_id = get_post_thumbnail_id( $post->ID );

    Thread Starter mcyzyk

    (@mcyzyk)

    My solution!:

    // Get PDF ID
    $fileURL = get_field(‘pdf’); <– “pdf” is the name of my Custom Field Type
    if($fileURL):
    $post_id = attachment_url_to_postid($fileURL);
    $pdf_id = get_post_thumbnail_id($post_id);
    endif;

    .
    .
    .

    <div class=”PDFThumbnail”>
    <?php
    echo get_the_post_thumbnail($post_id, ‘small’);
    ?>
    </div>`

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘But how to get $pdf_id for the current Post?’ is closed to new replies.