WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 have code that has been working for a long time which when a user clicks a button to order database results by name/value, it gets the results via AJAX from a page that does all the querying.

I have recently moved the entire site to a new dedicated server and changed some javascript files around, but for some reason the ordering has now stopped working. Here is my code:

    if($pageType == 'prize-home'){

    if($orderby == 'pointsvalue'){ //Must have these if statements because if its ordered by pointsvalue, its orderby meta_value_num, but if its a srting (smalltitle) its orderby meta_value
        $my_query = new WP_Query('post_type=prizes&showposts='.$per_page.'&meta_key='.$orderby.'&orderby=meta_value_num&order=asc&paged='.$page);
    }elseif($orderby == 'smalltitle'){
        $my_query = new WP_Query('post_type=prizes&showposts='.$per_page.'&meta_key='.$orderby.'&orderby=meta_value&order=asc&paged='.$page);
        $my_query = new WP_Query('post_type=prizes&showposts='.$per_page.'&meta_key=smalltitle&orderby=meta_value&order=asc&paged='.$page);

        while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $my_meta = get_post_meta($post->ID,'_my_meta',TRUE); 

        $pointsvalue = get_post_meta($post->ID,'pointsvalue',TRUE);
        $bigtitle = get_post_meta($post->ID,'bigititle',TRUE);
        $smalltitle = get_post_meta($post->ID,'smalltitle',TRUE);
        $productUrl = get_post_meta($post->ID,'producturl',TRUE);
        $imageUrl = get_post_meta($post->ID,'imageurl',TRUE);

        $no_of_paginations = $my_query->max_num_pages;

It now loads different pages (paginated results) fine, but when the order button is clicked it doesnt really do anything. Some things move about occasionally but it doesnt sort the results alphabetically.

I really dont think I have changed anything but Ive been trying different things all day with this and its getting frustrating. Has anyone has a similar experience? All console firebug results seem fine - as in all the query parameters are being passed over properely etc...

share|improve this question
up vote 0 down vote accepted

Some things to check. Have permissions changed during your migration? Sometimes those things change unexpectedly. Use Chrome inspector to see if any Javascript is failing to load (look for the red x).

Have you updated permalinks?

Is your new dedicated environment able to support the requirements of everything you're running?

If your code hasn't changed, but only your hosting environment, you'll want to look there first. Do you have access to error logs? Look for resources failing to load.

share|improve this answer
Thanks for the help. Turns out it was the Post Types Order plugin interfering with my wp_query hook :/ . Yayy!! – JamesG Apr 30 '12 at 9:13

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.