• I have a site running locally with MAMP and it’s working just as expected. I have a query set up on a page using a “blog” template. In that blog template I call WP_Query to grab the posts I want and I use the following setup:

    $args = array(
    	'cat' => of_get_option('category_blog'),
    	'category__not_in' => array(15),
    	'showposts' => of_get_option('postnumber_blog'),
    	'paged' => $paged
    );
    $wp_query = new WP_Query($args);
    
    if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();

    Note that the cat and showposts lines are populated using Theme Options. This works perfectly on my local system.

    Now I take a snapshot of the database, and upload all my web files, changing the URLs appropriately in the database to put onto my web server. This is where the weirdness happens. Apparently by keeping the “category__not_in” line all my posts revert to oldest to newest order as opposed to newest to oldest (which is the default of course). I even set order and orderby to be ‘ASC’ (and also tried ‘DESC’) and date. This changes nothing.

    It’s so strange because both servers are using the exact same code. The only difference I see is their PHP and MySQL versions but my host insists that the versions shouldn’t matter. My local MAMP uses PHP 5.3.6 and MySQL 5.5.9 and my live web host uses PHP 5.2.17 and MySQL 5.1.49

    Any suggestions here as to what might be the issue? Thanks!

  • The topic ‘Weird issue with category__not_in and post ordering’ is closed to new replies.