• Resolved thomas_schreiber

    (@thomas_schreiber)


    Hi,

    In the admin panel -> settings -> reading, you can set the amount of posts your blog shows withtin one page. Let’s say you set it to three posts per page, and the third post will be positioned last with “go to next page” link. Unfortunately the number of posts shown in one page also effects the result of my search.php page. The result is, that if I search for a common word, the result list is also limited to show only three results although there should be a lot more results.

    I’m using the <?php the_title(); ?> and <?php the_excerpt(); ?> tags to show to show the result as a teaser, but it’s a bit lame only being able to show a few results form the search engine.

    How do I show all search results in a single page or at least get the option to choose how many results I wont to show per page?

    Thank you in advance
    Thomas Schreiber ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • try the plugin search everything

    Thread Starter thomas_schreiber

    (@thomas_schreiber)

    Ok, thanks for the advice, but I like to keep my WP “plugin free” if possible.

    Thanks,

    // Thomas

    Thread Starter thomas_schreiber

    (@thomas_schreiber)

    I’ve tried the plugin but it still only shows the same amount of search results as I set my posts to on my blog ??

    Anyone else?

    // Thomas

    Assuming your theme has got a search.php, open it up, find this..
    <?php if (have_posts()) : ?>
    Above that, place this code..
    <?php query_posts('showposts=999999'); ?>

    Of course if you want the search the results less then nearly a million then change the number… ??

    Tested as working.

    Thread Starter thomas_schreiber

    (@thomas_schreiber)

    t31os_,

    Thank you very much. This solved my problem ??

    // Thomas

    Good stuff… ??

    Hi t31os_ ,

    I found this topic through the search but:

    It does NOT work for me on WP 2.7.1. The search results produces the set number of newest posts only. To be more precise: if the search word does not exist, I get “nothing found” but if the searchword exists, I get the set number of newest posts ignoring the searchword.

    Just used t310s’ directions. Excellent – and thank you.

    alistairrobinsongmailcom

    (@alistairrobinsongmailcom)

    I’m using 2.8.6 and the solution above, using query_posts(), didn’t work for me. I got the same result that henkholland got. Finally I used the following solution, after adding a new option to the wp_option table, “posts_per_archive_page”.

    In query.php, I changed this…

    if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )     $q['posts_per_page'] = get_option('posts_per_page');

    to this…

    if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 ) {
      if ($this->is_archive || $this->is_search || $this->is_category) {
        $q['posts_per_page'] = get_option('posts_per_archive_page');
      }
      else {
        $q['posts_per_page'] = get_option('posts_per_page');
      }
    }

    I found this update to t310s recommendation which is working for me on 2.8.6:

    <?php query_posts($query_string . '&showposts=10'); ?>

    That will show 10 results per page without showing ALL posts.

    Has been a while since i made the suggestion further up, here’s a refined version to do the same.

    // Create the paged var, for paging reults, if not showing all on one page then you might remove the paged lines.
    $paged =
    	( get_query_vav('paged') && get_query_var('paged') > 1 )
    	? get_query_var('paged')
    	: 1;
    // Create some args
    $args = array(
    	'posts_per_page' => -1,
    	//'posts_per_page' => 10,
    	'paged' => $paged
    );
    // Check if there's already query vars, and merge with args if there is
    $args =
    	( $wp_query->query && !empty( $wp_query->query ) )
    	? array_merge( $wp_query->query , $args )
    	: $args;
    // Now set the query with custom args etc..
    query_posts( $args );

    I use something like the above for most of my template files, so i don’t mess with any other query vars when passing in my own args/params..

    Hope that is of help to someone.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Show all content on search page’ is closed to new replies.