Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been trying to find a way to hide/deactivate the Parent dropdown menu from the Posts -> Categories screen.
http://example.com/wp-admin/edit-tags.php?taxonomy=category

I was able to hide the "Slug" option through this function here:

// Admin - Global Terms Enabled
function disable_global_terms($enablefalse) {
   return 1;
}
add_filter( 'global_terms_enabled', 'disable_global_terms' );

Is there a way I can do the same for the Parent Drop Down menu without deleting that code from the main WP files so I would have to do this each time with each update?

share|improve this question
    
What menu exactly are you talking about? –  toscho Jul 18 '12 at 6:38
    
Hey Toscho, the Parent Drop Down menu that I'm talking about is located in a Post Type's submenu "Categories"... where you can view more categories of a Post Type, add a new category, give theme a description, etc. –  Roc Jul 20 '12 at 16:36

1 Answer 1

If you are deleting code from the main WordPress files, this means that you know your way around a whole bunch of PHP files, so it's time now to learn how to do things without touching core files.

Side note to the hook presented in the Question:
the filter global_terms_enabled only works for Multisite (/wp-includes/functions.php, line 3006).

In many cases, there are no hooks to modify the administrative interface, so the modification needs to be done with CSS or jQuery.
The solution bellow shows how to print scripts in a specific screen (edit-tags.php) of the admin_head-SCREEN-ID.php. There, many checks can be done, in this case URL params.

add_action( 'admin_head-edit-tags.php', 'wpse_58799_remove_parent_category' );

function wpse_58799_remove_parent_category()
{
    // don't run in the Tags screen
    if ( 'category' != $_GET['taxonomy'] )
        return;

    // Screenshot_1 = New Category
    // http://example.com/wp-admin/edit-tags.php?taxonomy=category
    $parent = 'parent()';

    // Screenshot_2 = Edit Category
    // http://example.com/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=17&post_type=post
    if ( isset( $_GET['action'] ) )
        $parent = 'parent().parent()';

    ?>
        <script type="text/javascript">
            jQuery(document).ready(function($)
            {     
                $('label[for=parent]').<?php echo $parent; ?>.remove();       
            });
        </script>
    <?php
}

Screenshot_1

Screenshot_1


Screenshot_2

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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