tags:

views:

58

answers:

2

I want to show last 5 posts in a wordpress page, but when i use this code it will return the whole posts body, while i have <!--more--> in my post and I want to show till this part. here is the code that I am using :

   <div>
        <ul>
            <? query_posts('showposts=5'); ?>
            <?php while (have_posts()): the_post(); ?>
            <li>
                <a href="<?php the_permalink() ?>"><?php the_contenet(); ?></a>
            </li>
            <?php endwhile; ?>
        </ul>
    </div>
A: 

I can't tell what you want; do you want a list of the last five posts, or to print the content of the last five posts?

Some things: you've mispelled the_content. And you have an unneeded closing tag: </a> And if you want a list of posts, the_content isn't what you want, anyway: you want the_title.

And, if you're using this inside the main wordpress Loop, it needs to be a new query so it doesn't conflict with The Loop:

<?php $my_query = new WP_Query('showposts=5'); ?><?php while ($my_query->have_posts()) : $my_query->the_post(); ?><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_content(); ?><?php endwhile; ?>

songdogtech
+1  A: 

Change it from the_content to the_excerpt then it shows a teaser instead of full content...

crosenblum
I did it , but it will not show until where I have put the <!--more--> command, it will cut wherever it wants !
Datis