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

I am using a drop-down to sort posts by title, meta_value, etc. However, the sorting feature only works on the first page. The second page displays the default order rather than continuing the order from page 1. I am using wp-pagenavi for pagination. Any ideas what would be causing this error?

Here's a link to the code:


Thanks so much.

share|improve this question

You're initially submitting a POST request via a form with the sort parameters. When you click links to additional pages, you're just sending a GET request for the next page without those original POST vars, so they don't carry over to the additional pages and aren't picked up by your if(isset($_REQUEST['sort'])). Probably the simpler way to handle it is to pass the sort parameter as a query string appended to the URL, then check for that query string and append it to the URLs of the additional pages.

share|improve this answer
Upvoted... didn't notice the form action. – s_ha_dum Nov 18 '12 at 21:14
Thanks for your feedback. I understand what you're saying. Unfortunately, I don't know enough PHP to know what this looks like in code. Would you be able to provide a coding example of what you're suggesting? Thank you very much. – John Hall Nov 18 '12 at 21:40

You are setting $paged after the if conditionals that use it.

// more uses of $paged that way ^^^^
        $order = array(
        'cat' => 30,
        'orderby' => 'title',
        'order' => 'ASC',
        'paged' => $paged

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

Put that $paged = line before those conditionals and I bet it makes a difference.

share|improve this answer

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.