Saturday, 12 May 2012

Show post in wordpress with image on first post

<?php function excerpt($num) {
    $limit = $num+1;
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt)."... (<a href='" .get_permalink($post->ID) ." '>Read more</a>)";
    echo $excerpt;
}
?>

<?php global $post;
$args = array( 'numberposts' => 5, 'orderby' => 'rand' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :    setup_postdata($post); ?>
    <h1 class="single blog"><a href="http://ads.indonetasia.com/external/reader.php?postid=<?php echo $post->ID ; ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    <a href="http://ads.indonetasia.com/external/reader.php?postid=<?php echo $post->ID ; ?>" rel="bookmark" title="<?php the_title(); ?>"><img src=<?php $alamatimg = catch_that_image();
    $alamatimg2 = "\"$alamatimg\"";
    echo $alamatimg2 ?> height="52" width="62" align="left" valign="top" /> </a>
    <?php excerpt('22');?>   
<?php endforeach; ?>

No comments:

Post a comment

Popular Posts