Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Created January 9, 2015 13:46
Show Gist options
  • Save blainerobison/8f6f81a0ca84bbd82ff9 to your computer and use it in GitHub Desktop.
Save blainerobison/8f6f81a0ca84bbd82ff9 to your computer and use it in GitHub Desktop.
wp: Hide Taxonomy Description [WordPress]
/**
* Hook into Admin_footer on taxonomy edit screens
*
* @return void
*/
function prefix_hide_term_metabox() {
global $current_screen;
$output = false;
switch ( $current_screen->id ) :
/**
* Hide description metabox on WooCommerce product brand taxonomy
*/
case 'edit-product_brand':
$output = true;
break;
endswitch;
if ( $output ) : ?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('#tag-description').closest('.form-field').remove();
$('#description').closest('.form-field').remove();
});
</script>
<?php endif;
}
add_action( 'admin_footer-edit-tags.php', 'prefix_hide_term_metabox' );
@amitbiswas06
Copy link

Probably the more authentic way is to enqueue scripts for this purpose. My code is -

/**
 * enqueue custom admin script(custom-admin-script.js) on taxonomy edit screens (my-taxonomy)
 */
function prefix_hide_term_description_metabox() {

    global $current_screen;

    if ( $current_screen ->id === "edit-my-taxonomy" ) :
        wp_enqueue_script( 'any-custom-name', plugin_dir_url( __FILE__ ) . 'custom-admin-script.js', array(), '1.0' );
    endif;
}
add_action( 'admin_enqueue_scripts', 'prefix_hide_term_description_metabox' );

And then, inside the "custom-admin-script.js", we need to place this piece of code -

(function($) {
    $(document).ready( function($) {
        $('#tag-description').closest('.form-field').remove();
        $('#description').closest('.form-field').remove();
    });
})(jQuery);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment