query.php error

HI,

Im using version 3.0.3 of the Pro Sites plugin and wp version 3.2.1

I get this error when I activate the plugin: Fatal error: Call to a member function get_queried_object_id() on a non-object in /public_html/wp-includes/query.php on line 58

I get this error on the places where I have a WP_Query in the code. for example:

$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query('posts_per_page=3');

If I remove the query the site does load. How can I fix this?

  • nielsmus
    • WPMU DEV Initiate

    They are part of the theme. and look like this:

    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query('posts_per_page=3');
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ...
    endwhile;
    $wp_query = null;
    $wp_query = $temp;
    wp_reset_postdata();

  • nielsmus
    • WPMU DEV Initiate

    I just found out the error does not happen when I first activate the plugin. The problem starts when I click "Save Changes" in the "settings" panel.

    Where are these settings saved? I can't find them back in my database. If I remove the plugin and re-install it afterwards. the same settings are still there and also the error.

  • nielsmus
    • WPMU DEV Initiate

    It seems like I resolved this issue by removing the $wp_query= null; from the query.

    $temp = $wp_query;
    //$wp_query= null;
    $wp_query = new WP_Query('posts_per_page=3');
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ...
    endwhile;
    $wp_query = null;
    $wp_query = $temp;
    wp_reset_postdata();

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.