Reputation: 471
I am working with wordpress latest version. As in wordrpess, we can add URL while adding a featured image in a post as there are text fields like caption, title, alt text, description, URL etc. I've added a link like http://example.com/abc-news I am fine to show the featured image in the blog post but I want that link as
<a href="URL" title="">{featured-image}</a>
So that, if anyone clicks on the featured image he/she will go to that link.
Any help would be appreciated.
Upvotes: 2
Views: 769
Reputation: 471
Thanks for your prompt reply.
You are right that it's 98% depending on the theme.
The theme is using a meta_value
to add a custom URL for the featured image.
So, I need to get that URL through get_post_meta
I've got from here.
And I am fine with it now. :-)
Thanks
Upvotes: 1
Reputation: 1805
If you are using the default theme with the latest version of WordPress, you can edit content.php in the 2014 theme directory.
You need to wrap <?php twentyfourteen_post_thumbnail(); ?>
with the link code pointing to your URL.
This code should be around line 13 in content.php.
<?php twentyfourteen_post_thumbnail(); ?>
To link to the current blog post, you could add this code:
<a href="' . esc_url( get_permalink() ) . '"><?php twentyfourteen_post_thumbnail(); ?></a>
If you are using a different theme than the default, open the file which contains The Loop in your theme, search for the_post_thumbnail
or a similarly named function, and change the code as above.
The exact answer will vary depending on theme, but 98% of the time the fix should be similar to the above. Hope this helps.
Edit: Here's some more information: http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Post_Thumbnail_Linking_to_the_Post_Permalink
Upvotes: 2