• Resolved ashshake

    (@ashshake)


    Hello I am using CPT-Onomies to create product categories with more fields and a nicer management offering than using a normal wordpress taxonomy. All is going well, though when you choose categories and save the post the selected category checkboxes are pulled out of the hierarchical structure and are moved to the top of the list.

    As the product categories list has multiple sub categories with the same name it makes it quite confusing as to which ones are actually selected. I have found a link that explains how to remove the standard wordpress category meta box and replace it with a version that forces the structure to remain in place:

    https://wordpress.stackexchange.com/questions/61922/add-post-screen-keep-category-structure

    I have tried to use it and replace the:

    if ( $metabox['callback'] == 'post_categories_meta_box' ){

    with the name of the meta box generated by your plugin but no dice ??

    Would you perchance have any suggestions as to a way of implementing this in code. It may be useful for other people too and possibly something that can somehow be added as an option in the plugin settings per cpt-onomy.

    Thanks very much for your time

    https://www.ads-software.com/plugins/cpt-onomies/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well, it uses the wp_terms_checklist() function so an easy way to fix this would be to use the ‘wp_terms_checklist_args’ filter:

    add_filter( 'wp_terms_checklist_args', 'my_website_wp_terms_checklist_args', 1, 2 );
    function my_website_wp_terms_checklist_args( $args, $post_id ) {
    
       // obviously replace this with your taxonomy or remove it altogether
       if ( 'actors' == $args[ 'taxonomy' ] ) {
          $args[ 'checked_ontop' ] = false;
       }
    
       return $args;
    
    }
    Thread Starter ashshake

    (@ashshake)

    Thanks Rachel this works beautifully!

    I’m still new to WP, though learning bit by bit. I probably should have figured this out by myself but alas my deadlines are always too tight.

    Great plugin by the way, I neglected to mention it before.

    Yay! And thank you. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Type Category Keep Structure’ is closed to new replies.