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!

Similar Posts

  • Coding at a new level

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!This semester I am taking a class called Machine Organization and Assembly Language. What this amounts to is learning how to…

  • |

    Stop Focusing on WordPress Searches and Serve Your Customers

    Over the last few months, we’ve seen several outlets report on the seemingly alarming decrease in search terms year-over-year in the WordPress space. But does it matter that the specific search terms are decreasing (sometimes marginally) even as WordPress and WooCommerce usage reach new heights. While well-meaning, I don’t think these reports solve the problem they think they’re solving.

  • Wednesday Scrapple 1

    I’ve been sharing a lot of links and such lately so I figured I’d try one of these Scrapple posts that Colin introduced me to.  Here we go! I’ll do a bigger write up on this (eventually), but every Tuesday you can pick up the OnePlus One without an invite. I absolutely love everything about…

  • |

    Book Review: HTML5 for Web Designers

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! HTML5 for Web Designers by Jeremy Keith is a book I pre-ordered when it was first announced and I finally got around…

  • Speaking at WordCamp Philly

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!Just a quick note that I’ll be speaking tomorrow (Oct 20th) at WordCamp Philly! My talk is called Building a Simple…

One Comment

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

Comments are closed.