tags:

views:

45

answers:

2

this is the basic loop

<?php while (have_posts()) : the_post(); ?>

i want to show 20 posts on the search results page, i know we can change the value on admin panel options. but it will change all i.e. index page and archive page etc. I need to have them differently.

thanks!

A: 

Great reference: http://codex.wordpress.org/The_Loop

Just before you call the while statement, you need to query the posts. So:

  <?php query_posts('posts_per_page=20'); ?>

  <?php while (have_posts()) : the_post(); ?>
    <!-- Do stuff... -->
  <?php endwhile;?>

EDIT: Sorry about the pagination, try this:

    <?php 
        global $query_string;
        query_posts ('posts_per_page=20');
        if (have_posts()) : while (have_posts()) : the_post();
    ?>
    <!-- Do stuff -->
    <?php endwhile; ?>

    <!-- pagination links go here -->

    <? endif; ?>
Jiert
That's great! works well. Thank you!
ray
Looks like the pagination won't work any more! any idea?
ray
change `posts_per_page` to `showposts`?
Gipetto
let me know if my edit above fixes the problem.
Jiert
A: 

If you don't want to make up a bunch of template files with different loops for different pages and preserve pagination, try http://wordpress.org/extend/plugins/custom-post-limits/

songdogtech