Custom Theme Want To Remove One Category From All Displays

I created my own custom WordPress theme for my website, everything is great. However, I have a strange need, I have one category which is kind of a ‘placeholder’ for content which is automated and used by an automated background process. Each time this process finds new content to put into that category I end up with another entry when I go to the admin screen to post or edit any of the posts which I manually enter. Since it is more than just myself, I really want a way to just completely hide that one category from being shown in the Admin ‘Edit/Post’ screen to keep it nice and lean.

I’ve poked around in some of the source code files, however, I have come to the point of frustration. Been searching around on Google and other places for any idea, yet, keep coming up empty.

Read More

Does anyone know how to do this, or even IF it can be done?

Thanks,

Derek

Related posts

Leave a Reply

2 comments

  1. The only solution I could imagine is removing, rewriting, replacing the meta box.

    // First remove the original one
    function wpse21483_remove_catbox()
    {
        remove_meta_box( 'post_categories_meta_box', 'post', 'side' );
    }
    add_action( 'admin_menu', 'wpse21483_remove_catbox' ); // not sure about the hook
    
    function wpse21483_new_catbox()
    {
        // re-define - take a look at /wp-admin/include/metaboxes.php
    }
    // Hook the new one
    add_action( 'add_meta_boxes', 'wpse21483_new_catbox' );
    

    Edit: Maybe you can use a the filter for the categories dropdown

    function wpse21483_alter_catbox( $output )
    {
        global $current_screen;
        $id = $current_screen->id;
        // abort if not on post screen
        if ( $id !== 'post' )
            return;
    
        // search/replace the category
        return $output;
    }
    add_filter( 'wp_dropdown_cats', 'wpse21483_alter_catbox', 10, 1 )