I recently found myself with a fatal error, which much to my surprise I’m seeing less and less while I traverse down my WordPress development journey. The error is below:
Fatal error: Call to a member function add_rewrite_tag() on a non-object blah blah blah
My first reaction was “Oh, great now WTF?!”, a quick Google search lead me to the WordPress Support forum. Were Nacin, a local WordPress developer of D.C. and one of the core developers on the WordPress project so kindly replied.
That shouldn’t have worked in 2.9 either, though you’d avoid the error. You have a plugin which is calling register_taxonomy() with URL rewriting, prior to us actually getting the rewriting module up and running. There’s a right way, and the plugin is doing it the wrong way.
There was no fix listed in the support forum and of course the Topic is Closed. The fix is simple, you just need to set rewrite to false.
register_taxonomy( $taxonomy, $post_type, array( 'rewrite' => false ) );
What caused my problem was that I’m adding default taxonomies and terms upon Plugin Activation. TheĀ register_activation_hook is one of the first things ran so some “stuff” wasn’t set-up yet.