WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a Custom Post Type product with the Custom Taxonomy product_category. When editing a product in WordPress, there is a problem with displaying the product categories tree view right.

When an item is checked, it will move to the top of the list. When this item is a top level category, the child categories stay in the same spot in the list and therefore aren't shown correctly.

When an subcategory is selected, it will also move to the top of the list. It isn't shown in the tree view anymore.

An example:

Before selecting:
O - A
O   - A.1
O   - A.2
O   - A.3
O - B
O   - B.1
O   - B.2
O   - B.3

After selecting:
X - A.2
X - B
O - A
O   - A.1
O   - A.3
O - B.1
O - B.2
O - B.3

O = unchecked
X = checked

I thinks it's a WordPress bug but I can't find the problem in the WordPress core files. Does anyone know a solution?

share|improve this question
up vote 3 down vote accepted

Found a solution. It is a WordPress builtin functionality, not a bug. Could be prevented with the 'wp_terms_checklist_args' filter.

Below an example for use with Custom Post Type 'product' and Custom Taxonomy 'product_category':

add_filter( 'wp_terms_checklist_args', 'checked_not_ontop', 1, 2 );

function checked_not_ontop( $args, $post_id ) {
    if ( 'product' == get_post_type( $post_id ) && $args['taxonomy'] == 'product_category' )
        $args['checked_ontop'] = false;

    return $args;


share|improve this answer

Your Answer


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.