0

How to disable categories/most used in 'add new post'? I tried function: remove_meta_box(), but it doesn't work for me, i tried it in functions.php for my theme, it's mistake?

2
  • Do you want to remove the whole Categories box or only the Most used tab?
    – brasofilo
    Commented Oct 31, 2012 at 0:07
  • @brasofilo - i wanted to remove the Most used tab and did it as above- look at next posts.
    – user23188
    Commented Nov 1, 2012 at 20:07

2 Answers 2

2

remove_meta_box removes the whole Categories box.

The Most used tab don't have any hook.

Don't modify WordPress core files, there's always a way to modify WP behavior without touching the core.

/**
 * Place the script in the theme's functions.php file
 */

add_action( 'admin_head-post-new.php', 'wpse_70874_hide_most_used_cats' );
add_action( 'admin_head-post.php', 'wpse_70874_hide_most_used_cats' );

function wpse_70874_hide_most_used_cats()
{
    // This function runs in all post types (posts, pages and cpts)
    // So we need to check for the correct type
    global $post;
    if( 'post' != $post->post_type )
        return;

    // If checking for a custom taxonomy, the <ul> id is 'custom-taxonomy-slug-tabs'
    // See /wp-admin/includes/meta-boxes.php, line 322, WP 3.4.2
    ?>
    <style type="text/css">
        #category-tabs .hide-if-no-js {display:none;}
    </style>
    <?php
}
1

In Add New Post, click on the Screen Options tab om the top right then uncheck Categories. If you want to change it for all users, you can either:

  • sign-in as the user and then change their screen option
  • edit your theme's function.php. there are a couple options here and here that might work for you
  • try to see if this old plugin still works with your version of wordpress
2
  • Thanks for help-very useful is schema for arrays in wp_meta_boxes, but i used other way - just add: ul#category-tabs li.hide-if-no-js {display:none;} in wp-admin.css and it works. i dn't see yet if it causes any aside problems in other place but i hope no:) On the other hand i don't know why code "remove_meta_box()" doesn't work...
    – Marcin
    Commented Oct 30, 2012 at 8:10
  • @Marcin, just be aware that CSS mod you made will be overwritten every time you update WP.
    – Gaia
    Commented Oct 30, 2012 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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