when i call this link ;


wp display my search query order by ASC.


how can we display whatever i want to display postnumber like 10 or more ?

is that possible ?

  • Could you precise your question ? What do you want to display ? The search results starting at the 10th one ? Or the post that has the id of 10 ? – Fabien Quatravaux Oct 20 '12 at 0:59
  • @FabienQuatravaux i want to display both. – Fatih Toprak Oct 20 '12 at 12:12

If you're asking to change the number of posts from 10 to something else, you can do one of the following

1) Submit the search query as


You can achieve this by adding hidden fields to the form. Just change the number to whatever you want

2) Go to Settings > Reading, change the setting there. This will change the setting for all the pages though

3) Add this to your theme's functions.php or in a plugin

add_filter('pre_get_posts', 'change_posts_on_search');
function change_posts_on_search($query) {
    if($query->is_main_query() && $query->is_search())
        $query->set('posts_per_page', 5); // change the number here


<form action="<?php echo home_url( '/' ); ?>" method="get">
    <input type="text" name="s" />
    <select name="posts_per_page">
    <input type="submit" />

This form does that work. Basically it's same as the first option above. But except for the hidden field, it shows the field to the user allowing for changes.

| improve this answer | |
  • You welcome. BTW, not Aggard :P – Mridul Aggarwal Oct 20 '12 at 13:07
  • Sorry about that @Mridul Aggarwal by the way, i have another question, how can we add a select option box for this query. when user select 10 i want to display 10 results when he select 20 i want to display 20 resulst ? could you give me an example please. ? – Fatih Toprak Oct 20 '12 at 16:02
  • 1
    updated the answer – Mridul Aggarwal Oct 20 '12 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.