11

I don't like the way the taxonomies are displayed within the Wordpress admin and was wondering if anyone knew the best way to hook in and change it. Currently if I select some terms within my post those selected terms go to the top of the list and the hierarchy is broken making it visually confusing for the user.

Please see these images for an idea of what I'm talking about

enter image description here enter image description here

I want to display the taxonomies exactly how they are displayed initially with just the correct terms ticked. Is there a way of doing this without having to edit the Wordpress core directly, I can't see any hooks for me to use.

Thank you for any help you can give!

Helen

  • 1
    That happens with all heirarchical taxonomies, it's extremely annoying! – Tom J Nowell Sep 5 '12 at 16:49
  • Nice question. +1. – Anh Tran Sep 5 '12 at 17:10
7

There is a plugin by Scribu called Category Checklist Tree that disables this "feature".

  • Brilliant, this looks like exactly the solution I needed! – FlimFlam Dec 11 '12 at 15:56
2

Backtrace

Let's first check where this actually happens:

The meta box gets added on post.php and post-new.php screens.

# inside ~/wp-admin/edit-form-advanced.php
// TAGS:
if ( !is_taxonomy_hierarchical($tax_name) )
    add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
// CATEGORIES:
else
    add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));

Then we move one file deeper into core to get to the definition/the meta box callback

// inside ~/wp-admin/meta-boxes.php
function post_categories_meta_box( $post, $box )

The categorychecklist tab is the one that holds the list. Inside the div, we got a function named wp_popular_terms_checklist($taxonomy);.

# inside ~/wp-admin/includes/template.php
<li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit">
<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
    <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
</label>
</li>

» Conclusion:

This means, that we ain't got a real chance to intercept this on plain server side level with WP filters/hooks and PHP.

Doing something like...

add_filter( 'wp_get_object_terms', '__return_empty_array', 20, 4 );

... would simply disable the checked boxes completely.

will update if I got more information and (maybe a solution)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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