Forums

Can't get a post's thumbnail URL (3 posts)

  1. morninj
    Member
    Posted 6 months ago #

    In the loop, I'm able to print a post's thumbnail inside an img tag, but I can't retrieve the thumbnail image's URL.

    Here's my code:

    <?php
    
    if (have_posts()) :
        while (have_posts()) : the_post();
    
            the_post_thumbnail($post->ID); // This works
            echo(wp_get_attachment_thumb_url($post->ID)); // This doesn't work
            echo(wp_get_attachment_url($post->ID)); // This doesn't work, either
    
        endwhile;
    endif;
    
    ?>

    Does anybody know why?

    Thanks!

  2. alchymyth
    The Sweeper
    Posted 6 months ago #

  3. morninj
    Member
    Posted 6 months ago #

    That did the trick. Thanks!

Reply

You must log in to post.

About this Topic