WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
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
up vote 2 down vote accepted

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.

share|improve this answer
Aggard i'll try than. Thank you. – Fatih Toprak Oct 20 '12 at 12:12
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
updated the answer – Mridul Aggarwal Oct 20 '12 at 17:57
Thanks you @Mridul I'm grateful. – Fatih Toprak Oct 20 '12 at 19:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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