18

I have a Drupal 7 site, and under the Content Types menu, only certain types have a 'delete' link under the 'Operations' column.

All of the content types have the links for 'edit', 'manage fields', and 'manage display', but only some have 'delete', while others don't.

I checked my permissions for my user, and I do have Administer content types -- but that appears to be one global permission for all content types, so I still don't understand why some are deletable while others aren't.

Why do only certain content types have a delete operation?

15

You can only delete content types that are created manually (via admin/structure/types/add).

Content types that don't have a delete link are created programmatically by installed modules and will be deleted after you uninstall them.

| improve this answer | |
  • 5
    In case anyone is still here -- I have a content type that was created programmatically, but is still hanging around my site even after I've deleted all traces of it from the site's code -- there are still entries for it in {menu_links} and {menu_router} and the like, so it's still showing up in "create content" menus and the like. Something has evidently gotten messed up along the way; is there any good way to get rid of this short of (ugh) directly hacking the database, which I would REALLY like to not do? – Jim Miller Jun 5 '12 at 0:15
  • I have the same problem. On a multisite, I exported a content type with the help of Features, and exported onto another. Now I removed the related modules but the content type is still here. – user9883 Sep 10 '12 at 12:34
  • 3
    You probably have, but just checking - have you uninstalled the modules as well as simply disabling them? – user56reinstatemonica8 Sep 10 '12 at 13:37
  • 2
    Here is the solution. – Aram Boyajyan Sep 23 '12 at 15:52
  • I don't know if this answer has been correct earlier, but it certainly isn't correct anymore with Drupal 7.23. Content types can be deleted, regardless of how they were created. – Kari Kääriäinen Sep 22 '13 at 20:16
31

Delete them by going to the url /admin/structure/types/manage/content-machine-name/delete

content-machine-name being the machine name of the content type you want to delete. Also, make sure you use dashes in the machine name rather then underscores.

| improve this answer | |
  • 1
    Awesome, this worked very nicely! I installed Enterprise Blog and Enterprise FAQ awhile back, but ended up not using them. The Content Types screen did not give an option for deleting those content types, so your method was a welcome relief! – hockey2112 Mar 11 '13 at 21:12
  • 1
    I didn't expect this to work, but it worked beautifully. Great for removing content types added using the Features Module. – Citricguy Jun 1 '13 at 6:44
  • Yep! This tip was awesome. Works well. – Boriana Ditcheva Aug 28 '14 at 20:58
  • This is the actual solution :) – petergus Feb 8 '16 at 12:36
  • This works, however, if the "delete" link doesn't naturally show up, it means that it might not be safe to delete. Once there are no content types using it, no dependencies, no cached content and variables and features that are using it, the link will show up. So, I advise to use this with caution. – Christia Apr 16 '18 at 21:17
2

As hpn mentioned You can only delete content types that are created manually.

But sometimes things do not go smoothly. The following steps have helped to delete content types. You need to backup the database before trying this.

[To manually delete a content type that was created 1 #16 Nedjo suggests in drupal.org:

  • Disable the feature. I've sometimes run into problems with this--a feature won't disable. In this case, remove the feature module code.
  • Determine the machine name of the content type to be deleted, e.g., 'mytype'.
  • In the database, revert the node_type table values to the defaults as if the content type were created manually through the UI:

mysql> UPDATE node_type SET module = 'node', custom = 1, modified = 1, locked = 0 WHERE type = 'mytype';

  • Clear caches to ensure the content type change is available.
  • Through the UI at admin/structure/types, delete the content type.

The above steps is what it has helped me before when I have found those problems.

| improve this answer | |
1

Disabling the module providing the content type should be the first step. If the content type was provided by a feature, you'll still need to delete the content type.

For a well-made Feature, the ability to delete a content type will come after the Feature providing it is disabled. This is preferred over deleting a content type out from under a feature, as current functionality or future updates to that feature may require the content type.

Note that you can disable feature modules (admin/modules) even when the the Features interface is (rather foolishly) claiming it cannot disable a module because of conflicts.

And if you don't want to do anything through the interface, and just want to do code, here's an example of an update hook that will disable the Commons Wiki and Posts Features and then delete the content types they provide.

<?php
/**
 * Remove unused features and content types.
 */
function example_update_7001() {
  // Delete one (spam) piece of wiki content.
  node_delete(2731);
  // Disable Feature modules.
  module_disable(array('commons_wikis_pages', 'commons_wikis', 'commons_posts'));
  // Delete content types.
  node_type_delete('wiki');
  node_type_delete('post');
}
?>
| improve this answer | |
0

I did this but I get this error message: Notice: Undefined index [content-type] in node_filter_form() Any idea how to fix this?

| improve this answer | |
  • This you should post as a separate question – user1359 Mar 23 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.