Category for Images

A long time ago you gave me the following code to add the category to my media files:

// ADD CATEGORY TO ATTACHEMNTS
function wptp_add_categories_to_attachments() {
register_taxonomy_for_object_type( ‘category’, ‘attachment’ );
}
add_action( ‘init’ , ‘wptp_add_categories_to_attachments’ );

This works all perfect - but I have the feeling that it now slows down my database :frowning: The problem is that I now have over 20,000 images in my blog and I have now assigned a category to every single picture.

Example:

I have a travel blog. So if the picture is in a report from Germany, it gets the category “Germany”. But the report itself also has the category “Germany”. So the category “Germany” is now mixed with posts and pictures.

This was never the case before. Under Posts > Categories > Germany only the posts were included, not the images. But now the images are counted there as well. This inflates the category Germany unnecessarily.

Is there a way to undo that? I can of course remove the code from the function.php. Then I would no longer specify categories for future images.

But how to delete the categories of the old images? They are not in a column in the database, are they? Is there a way? I hope you can help me.

Hey @michaelxxx ,

Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. That is even if we have provided a sample here in the forum. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.