Skip to content

Instantly share code, notes, and snippets.

@grok
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grok/48227330fe73e9f78f78 to your computer and use it in GitHub Desktop.
Save grok/48227330fe73e9f78f78 to your computer and use it in GitHub Desktop.
I don't really like categories. I prefer tags. Let's hide what's not going to be used.
<?php
namespace ChangeMe\Theme\Modules;
class Core {
public function __construct() {
add_action('admin_init', array($this, 'disable_category_feature'));
add_filter('rewrite_rules_array', array($this, 'remove_category_rewrites'));
}
public function disable_category_feature() {
unregister_widget('WP_Widget_Categories'); // Remove widget.
register_taxonomy('category', array()); // Unhook all the category "functionality" but leave the data.
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category'); // Hide Administration menu.
}
// Permalinks for categories can go.
public function remove_category_rewrites($rules) {
foreach($rules as $rule => $rewrite) {
if(preg_match('/^category/', $rule)) {
unset($rules[$rule]);
}
}
return $rules;
}
}
$theme = new \ChangeMe\Theme\Modules\Core();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment