I am trying to fetch and show all posts in a featured listing style for tag my-guide
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>
This code fetch all featured image from posts, however I am trying to fetch it via particular tag, I tried this also but its not working for tag query_posts('tag=my-guide'); –
<?php query_posts('tag=my-guide');
while (have_posts()) : the_post();
?>
<div class="breaking">
<img src="<?php echo get_post_meta($post->ID, 'thumbnail',true) ?>" alt="Post Image" class="postimg" />
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<p class="datetime"><?php the_time('l, F j, Y G:i'); ?></p>
<?php the_content('Continue...'); ?>
<div class="postmeta">
<p><?php the_category(', '); ?> - <a href="<?php the_permalink() ?>#commenting" title="View Comments">
<span class="comm"><?php comments_number('0 Comments','1 Comment','% Comments'); ?></span></a></p>
</div><!--/postmeta-->
</div><!--/breaking-->
<?php endwhile; ?>
Source of this -> http://net.tutsplus.com/tutorials/wordpress/build-a-featured-posts-section-for-wordpress/
I fixed the code on my own –
The problem with the second code block is that, no value is pouring in for this –
$post->IDSo this method call is not doing any good in the code –
To fix this, simply call,
<?php the_post_thumbnail(); ?>instead of<img src="<?php echo get_post_meta($post->ID, 'thumbnail',true) ?>" alt="Post Image" class="postimg" />So this is the working code in
generalfor a particular tag post display –