cpt

  • 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!

  • Upcoming Speaking Events

    As it turns out, I’m speaking a couple of times next week on WordPress Custom Post Types- check out the information below and register if you’d like!

    Connecting Custom Post Types
    WP Summit, Online, June 11th, 2013 at 12pm CST
    Use the code 20JOE for 20% off.
    DIY Custom Post Types
    NEPA WP Meetup, Library at The University of Scranton, Scranton, PA, June 13th, 2013 at 7pm EST