Title: Adding categories to Administrator role notes
Last modified: August 22, 2016

---

# Adding categories to Administrator role notes

 *  Resolved [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/)
 * I tried the following code in my theme’s functions.php file and I am not having
   any luck. Could use some help..
 *     ```
       add_action('init', 'h_administrator_add_default_boxes');
   
           function h_administrator_add_default_boxes() {
           register_taxonomy_for_object_type('category', 'h_administrator');
           register_taxonomy_for_object_type('post_tag', 'h_administrator');
           }
       ```
   
 * What I am really looking for is a way to group notes.. I could use parent/child
   notes to “fake” groups, but this is not REALLY what I want.. I would like to 
   be able to tag/categorize notes so I can sort or filter them..
 * [https://wordpress.org/plugins/role-based-help-notes/](https://wordpress.org/plugins/role-based-help-notes/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288322)
 * Your code works fine for bringing up the meta boxes within the admin side editing(
   just tried it). What’s your probably exactly are you not getting the meta boxes
   or not able to show the categories on the front end of the site?
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288348)
 * Ahhhh.. sorry Justin.. this is totally MY BAD here!!! I was not seeing the meta
   boxes in the admin when editing notes.. THEN after reading your post I had an
   EPIPHANY!!! I am using the Dynamik-Gen theme (a Genesis child theme).. Forgot
   all about that little “Affect Admin” checkbox in the functions file editor.. 
   DOH.. Once I clicked that little button, it was a done deal..
 * Sorry.. Your response got me on track though.. If nothing else ya jarred my memory..**
   giggle**
 * On an related note.. what would it take to add a custom taxonomy to this plugin
   so that it maintains it’s OWN categories versus using the post categories??
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288354)
 * I think I figured this out on my own..
 * Found this tutorial:
    [http://www.wpbeginner.com/wp-tutorials/create-custom-taxonomies-wordpress/](http://www.wpbeginner.com/wp-tutorials/create-custom-taxonomies-wordpress/)
 * With one MINOR change, I used the code in this article pretty much as is.. Sharing
   the code I used below..
 *     ```
       //hook into the init action and call create_book_taxonomies when it fires
       add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
   
       //create a custom taxonomy name it topics for your posts
   
       function create_topics_hierarchical_taxonomy() {
   
       // Add new taxonomy, make it hierarchical like categories
       //first do the translations part for GUI
   
         $labels = array(
           'name' => _x( 'Topics', 'taxonomy general name' ),
           'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
           'search_items' =>  __( 'Search Topics' ),
           'all_items' => __( 'All Topics' ),
           'parent_item' => __( 'Parent Topic' ),
           'parent_item_colon' => __( 'Parent Topic:' ),
           'edit_item' => __( 'Edit Topic' ),
           'update_item' => __( 'Update Topic' ),
           'add_new_item' => __( 'Add New Topic' ),
           'new_item_name' => __( 'New Topic Name' ),
           'menu_name' => __( 'Topics' ),
         ); 	
   
       // Now register the taxonomy
   
         register_taxonomy('topics',array('h_administrator'), array(
           'hierarchical' => true,
           'labels' => $labels,
           'show_ui' => true,
           'show_admin_column' => true,
           'query_var' => true,
           'rewrite' => array( 'slug' => 'topic' ),
         ));
   
       }
       ```
   
 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288359)
 * Brilliant 🙂
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288383)
 * and to add a dropdown filter for my new “Topics” taxonomy I followed the instructions
   here.. [http://wordpress.org/support/topic/add-taxonomy-filter-to-admin-list-for-my-custom-post-type?replies=2](http://wordpress.org/support/topic/add-taxonomy-filter-to-admin-list-for-my-custom-post-type?replies=2)
 * This is the code I used (modified for the custom post type & custom taxonomy):
 *     ```
       function restrict_h_administrator_by_topics() {
           		global $typenow;
           		$post_type = 'h_administrator'; // change HERE
           		$taxonomy = 'topics'; // change HERE
           		if ($typenow == $post_type) {
           			$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
           			$info_taxonomy = get_taxonomy($taxonomy);
           			wp_dropdown_categories(array(
           				'show_option_all' => __("Show All {$info_taxonomy->label}"),
           				'taxonomy' => $taxonomy,
           				'name' => $taxonomy,
           				'orderby' => 'name',
           				'selected' => $selected,
           				'show_count' => true,
           				'hide_empty' => true,
           			));
           		};
           	}
   
           	add_action('restrict_manage_posts', 'restrict_h_administrator_by_topics');
   
           	function convert_id_to_term_in_query($query) {
           		global $pagenow;
           		$post_type = 'h_administrator'; // change HERE
           		$taxonomy = 'topics'; // change HERE
           		$q_vars = &$query->query_vars;
           		if ($pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0) {
           			$term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
           			$q_vars[$taxonomy] = $term->slug;
           		}
           	}
   
           	add_filter('parse_query', 'convert_id_to_term_in_query');
       ```
   
 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288425)
 * This would be something I’ll put on the ToDo list so that any role or custom 
   role has a ‘topics’ category (or something similar). Having it in the plugin 
   itself helps if themes are swapped it won’t break anything.
 * One thing you might want to add to your site till then would be an additional
   menu pick to edit the ‘topics’. To do this add the following code into your function.
   php.
 *     ```
       // manually add the taxonomies as sub-menus
       add_action('admin_menu', 'add_tax_menus' );
   
       function add_tax_menus() {
       	add_submenu_page('notes.php', 'Topics', 'Topics', 'manage_categories', 'edit-tags.php?taxonomy=topics');
       }
       ```
   
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288443)
 * > One thing you might want to add to your site till then would be an additional
   > menu pick to edit the ‘topics’. To do this add the following code into your
   > function.php.
 * Justin you are a doll!!!! I was just on the hunt for this very code snippet..**
   lol**
 * > Having it in the plugin itself helps if themes are swapped it won’t break anything.
 * I totally agree.. However for this site, even if I swapped themes, I am using
   the Genesis framework so I wouldn’t lose anything, but because I wanted to make
   it easy for me to implement this on the next site I use the Role Based Help Notes
   plugin on, I actually packaged this code up as a down and dirty “helper plugin”
   on my site so that it’s “portable”..
 * Here’s the whole thing:
 *     ```
       <?php
       /*
       Plugin Name: Role Based Help Notes - Add Taxonomy
       Plugin URI: http://overthehillweb.com
       Description: Add custom taxonomy to Role Based Help Notes plugin
       Version: 1.0
       Author: Over The Hill Web Consulting
       Author URI: http://overthehillweb.com
       */
       /**
        * If this file is called directly, abort.
        */
       if ( ! defined( 'WPINC' ) ) {
           die;
       }
   
       /*Add custom taxonomy to Role Based Help Notes plugin*/
       //hook into the init action and call create_book_taxonomies when it fires
       add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
   
       //create a custom taxonomy name it topics for your posts
   
       function create_topics_hierarchical_taxonomy() {
   
       // Add new taxonomy, make it hierarchical like categories
       //first do the translations part for GUI
   
         $labels = array(
           'name' => _x( 'Topics', 'taxonomy general name' ),
           'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
           'search_items' =>  __( 'Search Topics' ),
           'all_items' => __( 'All Topics' ),
           'parent_item' => __( 'Parent Topic' ),
           'parent_item_colon' => __( 'Parent Topic:' ),
           'edit_item' => __( 'Edit Topic' ),
           'update_item' => __( 'Update Topic' ),
           'add_new_item' => __( 'Add New Topic' ),
           'new_item_name' => __( 'New Topic Name' ),
           'menu_name' => __( 'Topics' ),
         ); 	
   
       // Now register the taxonomy
   
         register_taxonomy('topics',array('h_administrator'), array(
           'hierarchical' => true,
           'labels' => $labels,
           'show_ui' => true,
           'show_admin_column' => true,
           'query_var' => true,
           'rewrite' => array( 'slug' => 'topic' ),
         ));
   
       }
   
           function restrict_h_administrator_by_topics() {
           		global $typenow;
           		$post_type = 'h_administrator'; // change HERE
           		$taxonomy = 'topics'; // change HERE
           		if ($typenow == $post_type) {
           			$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
           			$info_taxonomy = get_taxonomy($taxonomy);
           			wp_dropdown_categories(array(
           				'show_option_all' => __("Show All {$info_taxonomy->label}"),
           				'taxonomy' => $taxonomy,
           				'name' => $taxonomy,
           				'orderby' => 'name',
           				'selected' => $selected,
           				'show_count' => true,
           				'hide_empty' => true,
           			));
           		};
           	}
   
           	add_action('restrict_manage_posts', 'restrict_h_administrator_by_topics');
   
           	function convert_id_to_term_in_query($query) {
           		global $pagenow;
           		$post_type = 'h_administrator'; // change HERE
           		$taxonomy = 'topics'; // change HERE
           		$q_vars = &$query->query_vars;
           		if ($pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0) {
           			$term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
           			$q_vars[$taxonomy] = $term->slug;
           		}
           	}
   
           	add_filter('parse_query', 'convert_id_to_term_in_query');
   
       	// manually add the taxonomies as sub-menus
       	add_action('admin_menu', 'add_tax_menus' );
   
       	function add_tax_menus() {
       		add_submenu_page('notes.php', 'New Topics', 'New Topics', 'manage_categories', 'edit-tags.php?taxonomy=topics');
       	}
       ```
   
 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288444)
 * Ok great thanks for the code.
    Why don’t you give the plugin a review 😉 always
   good to hear how people are using it and how to make it better but yet kept simple.
 * .. Justin
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288451)
 * Happy to do that Justin.. I had a LONG journey looking for a plugin like this
   one.. So I am HAPPY to write a review!!!
 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288584)
 * You’ll see version 1.3.1 now has the topics taxonomy but not only the Admin role
   all roles have the benefit. Yours will be named different in the taxonomy naming
   set-up so both should be OK together its just up to you if you want to move over
   to the plugin version. 🙂
 * there’s a widget too if you want to make use of it.
 *  Thread Starter [DivaVocals](https://wordpress.org/support/users/divavocals/)
 * (@divavocals)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288585)
 * Justin you are a DOLL!!! So I should deactivate my plugin then correct???
 *  Plugin Author [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * (@justinticktock)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288586)
 * Yes there won’t be much point for both… if you have database knowledge I’m sure
   you could swap the taxomony details over to the new version of topics but it 
   maybe just easier to manually reassign and create.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Adding categories to Administrator role notes’ is closed to new replies.

 * ![](https://ps.w.org/role-based-help-notes/assets/icon-256x256.png?rev=1028105)
 * [Role Based Help Notes](https://wordpress.org/plugins/role-based-help-notes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/role-based-help-notes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/role-based-help-notes/)
 * [Active Topics](https://wordpress.org/support/plugin/role-based-help-notes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/role-based-help-notes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/role-based-help-notes/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [Justin Fletcher](https://wordpress.org/support/users/justinticktock/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-categories-to-notes/#post-5288586)
 * Status: resolved