Fixing the Fatal ‘add_rewrite_tag()’ Error
I’m working on a WordPress little side project where I am registering a new Custom Post Type and Taxonomy and came across this:
Fatal error: Call to a member function add_rewrite_tag() on a non-object...
After doing a Google Search to try to figure out what the issue is, all I came up with was “disable all of your plugins and reenable them to see which is the bad one.” That doesn’t help me because I know the one I’m developing is the bad one. My next step was just do to a Find for the term ‘rewrite’ and wouldn’t you know it, I came up with the the solution.
As it turns out, I was trying to register the taxonomy for my CPT before actually registering the CPT. If you ever run into the error yourself, try moving ” register_taxonomy” onto the line directly under the link that has “register_post_type.” My code was below it, but due to certain hooks I called, register_taxonomy was getting called first.
You might also want to prefix your taxonomies and CPTs; conflicts can arise that may also lead to that error. Happy Coding!

I also kept finding the same “Disable plugins” lol, not much help when you’re the dev. Much appreciated!