Reputation: 147
I have displayed the content to a specific post on my homepage however I want to have that content wrapped in an anchor tag so that it links to the full post page when clicked on. My code is:
<div class="key_product">
<?php
$post_id = 105;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo get_the_post_thumbnail($post_id);
?>
</div>
I am having trouble getting it to work. How can I accomplish this?
Upvotes: 0
Views: 108
Reputation: 18833
You can use get_permalink the way you use get_post: http://codex.wordpress.org/Function_Reference/get_permalink
$post_id = 105;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
$permalink = get_permalink($post_id);
echo '<a href="' . $permalink . '">' . get_the_post_thumbnail($post_id) . '</a>';
However, the permalink is likely in the $queried_post object. You can print_r($queried_post)
to inspect it.
Upvotes: 1