• Resolved harco

    (@harco)


    I’m building a website in WP 2.7 and tried to use the events category plugin, because it offered the exact functionality I was looking for. Now I know this plugin isn’t supposed to be compatible with the 2.7 version (yet?), but I tried it anyway and it worked like a charm… for some time.

    Then I got this:

    Fatal error: Call to a member function get() on a non-object in ../wp-content/plugins/events-category/events-category.php on line 270

    I can’t think of anything that would justify a fatal error like this… I had just finished writing a test comment, when it popped up. And even after deleting the comment (and the post), the error remained. If I deactivate the events category plugin, the error is gone. But then my events page isn’t working like it’s supposed to either 😉

    This is what it says on line 270:

    if($wp_query->get('name'))

    And is part of this piece of code:

    if(empty($catIDs)) {
    		#This conditional is needed because if going to non-existent post under events category, it will think
    		#   that it is not single
    		if($wp_query->get('name'))
    			return false;
    
    		$category__in = $wp_query->get('category__in');
    		if(!empty($category__in))
    			$catIDs = $category__in;
    		if($wp_query->get('cat'))
    			$catIDs[] = (int)$wp_query->get('cat');
    	}

    Has anybody got any idea what has happened here? I’m no php wizard, so I’m having a hard time understanding this. Any help or explanation is very much appreciated. I would love to understand this and get it working again.

Viewing 11 replies - 1 through 11 (of 11 total)
  • I’m not familiar with the plugin, but the PHP error message basically says $wp_query isn’t an object (which it’s supposed to be). You should stick a var_dump($wp_query) in there and find out what it is then!

    A quick and dirty fix – depending on the circumstances – might be adding a ‘global $wp_query’ in the plugin file …

    Thread Starter harco

    (@harco)

    Thanks for the help Arno! I thought that was what it meant, but I didn’t fully understand it…

    However I have no idea how to add a global $wp_query in the plugin file to try and fix this thing… Or how to stick a var_dump($wp_query) in there for that matter.

    Can you help me some more?

    Try adding the ‘global $wp_query’ before your ‘if(empty($catIDs))’
    If that doesn’t fix it you should put in the var_dump($wp_query) instead and post the PHP message here.

    Thread Starter harco

    (@harco)

    Thread Starter harco

    (@harco)

    Adding the ‘global $wp_query’ before your ‘if(empty($catIDs))’ doesn’t work. The PHP message after adding var_dump($wp_query) is:

    NULL
    Fatal error: Call to a member function get() on a non-object in ../wp-content/plugins/events-category/events-category.php on line 270

    Oh, and the plugin is here: http://wordpress.org/extend/plugins/events-category/. Maybe that helps?

    I had a look at the plugin and apparently it already uses a global $wp_query in the function you’re getting the error in. For some reason however $wp_query is not being set properly (eg. var_dump reported it as NULL)

    You could try setting it up yourself, but I don’t really know that much about this plugin … Sorry!

    http://codex.wordpress.org/Function_Reference/WP_Query

    Thread Starter harco

    (@harco)

    Too bad, but thanks a lot for looking into this and your help so far Arno!

    I don’t know how to set up $wp_query myself. Even with the help of the function reference. So basically I now have to find the reason why $wp_query is not being set properly even though global $wp_query is in the function. And since the plugin worked before, I should probably look for some cause in my templates? It’s just that I haven’t the faintest idea where I can best look for reasons why $wp_query is not being set properly and I’ve been looking for hours.

    Suggestions anyone?

    Thread Starter harco

    (@harco)

    I solved my problem by making some modifications to my templates that allow me to use a different plugin to do the same job.

    Hi harco,
    I’m having the same issue you were having w/ the events category plugin. It did work fine before, I dont know what I did to cause it to start.

    I wanted to ask what plugin you ended up using as a replacement to the events category.

    Thanks,
    James

    Thread Starter harco

    (@harco)

    I ended up using Event Calendar plugin in combination with The Future is Now! plugin.

    I post events in the category specified by the Event Calendar plugin AND in my ‘archive’ category. I changed my templates to make event posts show in my ‘archive’ category after the end date specified by the Event Calendar plugin (using The Future is Now! plugin).

    Hope this helps you.

    Here’s an update to the issue.

    I found this problem did not exist in other browsers. So I was able to remove the cookies (just for that website), and the problem has seemed to have gone away.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Fatal error: Call to a member function get() on a non-object’ is closed to new replies.