WordPress.org

Forums

Do NOT Put checked cats on top (4 posts)

  1. moikirsch
    Member
    Posted 6 years ago #

    Is there a way to force the admin to display the categories just like when your adding a new post without reordering them?

    If you have some type of hierarchy, it completely screws up the editing since you can have more than one subcategory with the same name.

    For example:

    - Windows
    -- Hardaware
    -- Software
    - Macintosh
    -- Hardware
    -- Software
    - Linux
    -- Hardware
    -- Software

    I know that it is related to the function wp_category_checklist and the walker but I can't think of a way to fixing it without editing the core and I really dont see why wordpress is forcing to change the hierarchy if all the parent category and so on is part of the core since I can remember.

  2. john.andrews
    Member
    Posted 5 years ago #

    While I don't recommend hacking core, this is a quick fix for what you need. Mentioned line numbers are specific to WP 2.8.4

    wp-admin/includes/template.php lines 522:532

    foreach( $keys as $k ) {
    	if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
    		$checked_categories[] = $categories[$k];
    		// comment out this --> unset( $categories[$k] );
    	}
    }
    
    // Put checked cats on top
    // comment out this --> echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
    // Then the rest of them
    echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));

    Hope that helps.

  3. Marko_J
    Member
    Posted 5 years ago #

    That really helped, thank you! It would be nice if this became a setting in WP's admin. When using (lots of) parent/child categories, it becomes quite a mess when WP moves the selected ones to the top...

  4. john.andrews
    Member
    Posted 5 years ago #

    Agreed @Marko_J. I'm working on a custom magazine WP instance at the moment and this really seemed more of a flaw then a feature (at least for our use). I've yet to check out 2.8.5 but don't assume this would have been addressed as there are better fish to fry.

Topic Closed

This topic has been closed to new replies.

About this Topic