Skip to content

WordPress, Custom Taxonomy, and “An unidentified error has occurred”

An unidentified error has occurred trying to list tags

Working on a plugin today, part of which includes a custom taxonomy, and came across a snag today.

Got the taxonomy added, along with the custom post type it was associated with. The meta box showed up just like it should. And I could type in items for the custom taxonomy and have them stick.

The snag was when I tried to type one in. The dropdown for auto complete would only show a 0. And clicking on the most used tags link would show “An unidentified error has occurred.”

Since this was the first time I’ve done anything with custom taxonomies, I was trying to make the fix way harder than it was.

The solution wound up being very easy. I just changed the priority on the add_action call that added my callback to admin_init to a lower number and it fixed it.

Published inWordPress


  1. Just to be complete on the steps you describe above. The taxonomy is created in functions.php.

    I tried your solution, by increasing the priority:

    which in my case produced the following code:

    add_action( 'init', 'create_ProductBrand',100 );

    but this didn’t work. Did I miss something here? What were the other solutions you tried?

    • Don’t remember what else I tried, although it involved watching a lot of network traffic with firebug.

      Not sure what part of this matters, but I’ve got my action callback tied to both the init and admin_init actions, both with a priority of 10. Something in that mix makes it work. Maybe init isn’t called by the ajax script? Not sure about that, but it’d be a place to start.

      • 10 should be the default priority, so in order to lower mine, I’ve set it to 100. No luck though.

  2. This turned out to be case-sensitivity for me:

    …was causing common/autocomplete to break,

    …works like a charm =)

    • Yes it works. query_var value (e.g. ‘your_taxonomy’) must match with the value of taxonomy term provided in register_taxonomy(‘your_taxonomy’, ……) function.

    • Yes! Thank you very much,
      it worked!!!

    • yeah case sensitivity. Exactly as described. No need to change the priority for me. The snippet I’m using has it set to “0”

  3. In my case, it was a space after closing ?> PHP tag. Try to go through all of your included theme files and remove any extra space after closing tag.

    • You can leave out the last closing PHP tag entirely. It doesn’t have to be there. And that’ll keep you from having to worry about white space after it.

  4. trish trish

    This problem continues to persist. In my case, the error was occurring because of an extra line (i.e. white space) BEFORE the opening tag in the functions file. Removing the extra line/space fixed the error.

    • Very nice .
      Now errror not showing .
      Every thing is working Well.
      Thanks trish

  5. Hiếu Hiếu

    I also did not apologize for this error

Leave a Reply

Your email address will not be published. Required fields are marked *