Support » Fixing WordPress » Get thumbnail by URL

  • Hi,

    I’m running a custom javascript function connected to an analytics API. This pulls the top 5 current articles on my WordPress site.

    The output is generated through a list containing the title and link of the post (pulled through the API). What I’d like to do is also display the appropriate thumbnail alongside the title, but as it’s not within a loop I cant use the_post_thumbnail, so my question is; is there any way of grabbing wordpress thumbnails via the URL of the post?

    Thank you in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    I don’t think you can do that.
    Only the post-attachments URL will be available for each post. but not the post thumbnail.

    I think you can use get_the_post_thumbnail($id, $size, $attr ) to get the featured image for any post outside the Loop.

    Thread Starter kallekillen

    (@kallekillen)

    I think the issue here is that not only is it outside the loop, but there’s no way to establish a connection between the thumbnail and the url as these aren’t generated until the page has been loaded (and the URL is being loaded via javascript while the thumbnail via php).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get thumbnail by URL’ is closed to new replies.