To delete all topics from a category, you will need access SSH access to your server. If you use managed Discourse hosting, get in touch with your provider and ask them to help. If you run your own server, here are the steps you need to take to delete all topics in a category:
This is a destructive action. Make sure to back up your forum before continuing
Deleting Categories
-
Find the “slug” of your category. This is the name of category used in the URL.
-
SSH into the server
-
cd /var/discourse
-
./launcher enter app
-
rake destroy:topics["mycategory"]
(replace “mycategory” with the slug of your category)
-
Wait… this may take some time, depending how many topics you have
Deleting Subcategories
To delete topics in a subcategory, you need to supply the parent category slug as well. For example, if “childcategory” is a subcategory of “parentcategory”, the command would look like
rake destroy:topics["childcategory","parentcategory"]
Delete All Categories
This will delete all topics in all categories!
To delete all topics in all categories, you can use the command:
rake destroy:topics_all_categories
Common Questions
How long Discourse stores deleted topics? I can still access topics with direct link.
The topics remain in the database forever. Only staff will still be able to see deleted topics
How can I delete topics from the database?
Topics cannot be deleted from the database.
Would it be possible to restrict the topic deletion to a time period (between two dates)?
You’d need do it from the rails consoles, a command similar to the following should work:
Topic.where("created_at.....").destroy_all
Is category ID the position on the categories page?
The category ID is what you’d see if you do
rake categories:list
Additional Information
For more information about other administrative operations please see:
Last Reviewed by @SaraDev on 2022-07-12T01:00:00Z
Last edited by @JammyDodger 2024-05-25T11:13:40Z
Check document
Perform check on document: