Thread Starter
bhang
(@bhang)
anyone…?
any help would be appreciate…
Thread Starter
bhang
(@bhang)
i already put this
<?php
$rand_posts = get_posts('numberposts=3&cat=6');
foreach( $rand_posts as $post ) :
?>
<p class="meta"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><p>
<p class="meta">Posted by <?php the_author() ?><strong>|</strong> <?php the_time('F j, Y, g:i a') ?></p><br />
<p><?php the_content(); ?><br /></p>
<?php endforeach; ?>
but the intro txt doesn’t appear..all i want the intro txt is appear in just 10 words with the thumbnail
any help..?
thanks
foreach( $rand_posts as $post ) :
?>
should be
foreach( $rand_posts as $post ) :
setup_postdata($post);
?>
Reference:
http://codex.wordpress.org/Template_Tags/get_posts#Access_all_post_data
Also need to add the_category to get categories so see the WordPress Default theme wp-content/themes/default/index.php for an example.
Thread Starter
bhang
(@bhang)
many thanks for your reply..it works
but i still can’t make the image appear as thumbnail..
i already saved the image as large image and thumbnail in media library..
what should i do to get the thumbnail one?
thanks in advance
This will display thumbnail image for post in loop
<?php
$images = get_children(
array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order'
)
);
if ( $images ) {
foreach ( $images as $id => $image ) {
$img = wp_get_attachment_thumb_url( $image->ID );
$link = get_permalink( $post->ID );
print "\n\n" . '<a href="' . $link . '"><img class="thumb" src="' . $img . '" alt="" /></a>';
}
}
?>
Thread Starter
bhang
(@bhang)
thanks michael..it works greatttt!!