Title: Help create a simple admin plugin
Last modified: August 18, 2016

---

# Help create a simple admin plugin

 *  Resolved [PozHonks](https://wordpress.org/support/users/pozhonks/)
 * (@pozhonks)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-create-a-simple-admin-plugin/)
 * I am trying to create a simple plugin to tweak the Write Post page in the admin
   area. My purpose is to choose only one category instead of several by changing
   the checkbox into a radio button. I can edit the core file in 30s, but I prefer
   a more elegant way by writing my first plugin.
    However, I think I’m missing 
   the right action of filter. I tried different combinations without success. Can
   someone help me? `function one_category_only() { // only when we are at post.
   php if(preg_match('|post.php|i', $_SERVER['REQUEST_URI'])) { $content = str_replace('
   type="checkbox" name="post_category', 'type="radio" name="post_category', $content);
   return $content; }} add_action('admin_footer' , 'one_category_only');
 * I tried several add_action and add_filter with different options without success.
   Or, is it much more complicated?

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

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-create-a-simple-admin-plugin/#post-466975)
 * It’s probably better to run something like this through PHP’s output buffering,
   like so:
 * `if(preg_match('|post.php|i', $_SERVER['REQUEST_URI'])) {
    ob_start('one_category_only');}
 * `function one_category_only() {`
    _etc…_
 * EDIT: Also, a version of your `if` test that takes less overhead:
 * `if(strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php')) {`
 *  Thread Starter [PozHonks](https://wordpress.org/support/users/pozhonks/)
 * (@pozhonks)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-create-a-simple-admin-plugin/#post-466985)
 * Thank you so much. It is working. I knew that the add_filter or add_actions was
   not appropriate in this case. Here is the full plugin code, for those interested
   to use it. Copy the code below, save the file as “onecatonly.php”, and download
   it to your plugins folder.
    `<?php /* Plugin name: One category only Version:
   0.1 Description: Replace the categories checkbox list in the admin area, by a
   radio button list, so that you choose only one category per post. Tested with
   WP 2.0.4. */ if(strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php')) { ob_start('
   one_category_only'); } function one_category_only($content) { $content = str_replace('
   type="checkbox" name="post_category', 'type="radio" name="post_category', $content);
   return $content; } ?>
 *  [xboomer](https://wordpress.org/support/users/xboomer/)
 * (@xboomer)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-create-a-simple-admin-plugin/#post-467148)
 * plz i need help there is now answer like this anywhere so i ask here. PLZ help
   i laod my admin plugin put in folderrs i write my ID and IP but when i join my
   serv it says am not an admin PLZZ HELPPPPPPPPPPPPP!!!!!!!! PLZZZZ

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

The topic ‘Help create a simple admin plugin’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [xboomer](https://wordpress.org/support/users/xboomer/)
 * Last activity: [19 years, 7 months ago](https://wordpress.org/support/topic/help-create-a-simple-admin-plugin/#post-467148)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
