I’m using timthumb.php and need to be able to get the url of the featured image of a post, when I use functions like the_post_thumbnail
it does more than just the url.
Here is the code so, the capital letters is where I need to insert the exact url, any help would be great, thanks.
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<img src="<?php bloginfo('template_url'); ?>/wp-content/themes/limerickfc/timthumb.php?src=<?php URL OF FEATURED IMAGE ?>&h=760&width=474" alt="" title="<?php the_title(); ?>" />
</a>
If your “thumbnail” images are large enough to do what you need:
Otherwise you’ll need to go for something like:
EDIT: The
array(300, 300)
bit is the image size you’d like to fetch. WP will substitute any image it has that is at least as large as what you asked for. You can also use'thumbnail'
,'medium'
,'large'
or'full'
to select one of the pre-configured sizes, as well as any name defined byadd_image_size()
in your template or plugins.First get the id of the featured thumbnail image:
One way to do it:
Another way would be:
Be careful about what is stored in the GUID and what is returned by
get_attachment_url
. The attachment url (depending on configuration) can be the page where the attachment is visitable (not the raw file URL but the page whereattachment.php
is used).