Wednesday, April 11, 2012

How to display latest posts in wordpress index.php(Just two post for this examples)

<?php if (have_posts()) : ?>
<?php query_posts("showposts=2"); // show one latest post only ?>
<?php while (have_posts()) : the_post(); ?>

<a style="text-decoration: none;" href="<?php the_permalink(); ?>" rel="bookmark"><h1><?php the_title(); ?></h1></a>
<p> <?php the_content(); ?></p>

<?php endwhile; ?>
<?php endif; ?>

No comments:

Post a Comment