Reputation: 599
I am working on a wordpress website. I have different category for one type of posts (call flowers for example). Suppose I have 10 posts in this category. I want to show 10 Images from these posts at home page (one image from one post )
After clicking on the image user will be redirected to the corresponding post.
Is this feasible in wordpress ? SHould i need to use custom fields or something which i found after googling.
Thanks
Upvotes: 0
Views: 94
Reputation: 3165
Setup a loop and query_posts() by the category that they are by the cat id
query_posts( 'cat=1' );
Then you could display a featured image for the post in your homepage loop, as so:
<?php if ( has_post_thumbnail() )
{
$image_id = get_post_thumbnail_id();
$alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
$image_url = wp_get_attachment_image_src($image_id,'large');
$image_url = $image_url[0];
?>
<a href="<?php the_permalink(); ?>">
<img src='<?php echo $image_url;?>' alt='<?php echo $alt_text; ?>' title='<?php echo $alt_text; ?>' />
</a>
<?php
}
else
{
?>
<a href="<?php the_permalink(); ?>">
<img src='<?php bloginfo('template_url'); ?>/images/no_image.jpg' />
</a>
<?php
}
?>
Upvotes: 1