in Tips, Tutorials, WordPress

Custom Post Type Taxonomy ‘Type’ Breaks Media Uploader

For months, whenever one of the writers at a big WordPress site I help run (Android Australia) tried to set a featured image or insert an image into a post, they were greeted with the following:

Basically, the media library tab would acknowledge that there were X amount of images but you couldn’t actually use any of the pre-existing media. Everything would need to be uploaded again. This became very tiring and frustrating as we wanted to reuse a lot of the images already existing on the site but instead had to manually re-upload each one.

I searched long and hard and couldn’t find a solution. I asked about it, googled it and cried about it. But then one day, almost magically, I found the solution.

Whilst creating a custom theme for Captain Theme, I was using a custom post type for Portfolio and had created the taxonomy ‘Type’, for users to filter their Portfolio items by. All of a sudden, the exact same media library issue appeared. I then realised that when you create the taxonomy ‘Type’, or at least register it under ‘type’, it clashes with a core WordPress function and as such breaks the media library dialogue.

So, this will break the media library (Bad):

But by simply adding portfolio_ or just changing it from ‘type’, it won’t break the media library (Good):

Hopefully this will save you the months of confusion it caused me.

Write a Comment