0

As currently there's no way to declare any new custom post format in WordPress (3.9.1), is there a way I can make the 'delete' button on some categories inactive, so that the Editor can't remove them, and I can call them where necessary with their IDs without any hustle.
delete button in categories

I just want it for some specific Categories only — not for all.

1 Answer 1

2

WordPress uses the WP_List_Table class, or some extension of it, to generate those lists. In this case, it is the WP_Terms_List_Table class. That class contains a filter called {$taxonomy}_row_actions.

add_filter(
  'category_row_actions',
  function($actions, $tag) {
    $no_del = array(11,22,33);
    if (in_array($tag->term_id,$no_del)) {
      unset($actions['delete']);
    }
    return $actions;
  },
  10,2
);
1
  • Thank you @s_ha_dum. I thought I could go with something like current_user_can('editor') and to target any capability like delete_categories (not exists) etc. But the solution is totally in a different place. Thanks a lot for the insights. Commented May 26, 2014 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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