Removing all subcategories from an existing category

I have a category with a large number of subcategories, each of which may have a number of topic postings. Is there a simple way for me to remove all of the subcategories and cause the existing topic threads in the various currently existing subcategories to instead appear under the main category itself after the subcategories are removed? Thanks!

1 Like

You can batch change categories by clicking on the batch select tool on the topic list and then re-assign categories to all the topics in one go.

That is the simplest way I can think of.

1 Like

Hmm. Thanks, but that doesn’t seem to work, in fact it messes things up pretty badly. It only appears to impact the top-level category name, and leaves all the subcategories intact. It also only will apply to one item at a time, even when they’re all in theory selected! Which I definitely don’t understand. I can see how to probably do this one item at a time by switching each one to a new category name, deleting the original category with the subcategories, then recreating it without the subcategories and moving them all back in individually, but that is going to be VERY time consuming.

If you need to bulk move all topics from a category to another category you can use the rails console.

Topic.where(category_id: <from_category_id>).update_all(category_id: <to_category_id>)

Doing the move through UI, you are not able to select many topics (I think only the first 30 or so) so if you have many topics in a category you should repeat the move many times before finishing.

2 Likes

I was ultimately able to move the topics using the interface, but I can’t delete the original category because of the subcategories. I don’t see any obvious way to delete those. No doubt I’m missing something obvious. By the way, when I moved those topics, a bunch of notifications were sent out for those old topics. That was unexpected. Thanks again.

1 Like

I have the same issue:




I think I deleted the sub-categories but discourse still thinks they exist.