Increasing The Categories Selection Height Dynamically In WordPress Admin
Increasing The Categories Selection Height Dynamically In WordPress Admin
If you manage a WordPress site with many categories, the default height of the category checklist in the post editor can feel cramped. This makes it difficult to see and select multiple categories without excessive scrolling. The quick fix is to increase the height of the category checklist dynamically in the WordPress admin area, improving usability and workflow.
Quick Fix
- Add a small PHP snippet to your theme’s
functions.php
file or a custom plugin. - Use admin CSS to increase the height of the category checklist container.
- Test the changes by editing a post with many categories.
Why This Happens
By default, WordPress sets a fixed height (usually 150px) on the category checklist box in the post editor. This height is hardcoded via CSS and does not adjust based on the number of categories. When you have many categories, the fixed height causes a scrollbar to appear, making it cumbersome to select multiple categories quickly.
Increasing the height dynamically or setting a larger fixed height improves the user experience by showing more categories at once without scrolling.
When to Use
- You have a large number of categories (20+).
- You frequently assign multiple categories to posts.
- You want to reduce scrolling in the post editor category checklist.
- You prefer a cleaner, more accessible admin interface.
Updated Code for Modern WordPress
The following code snippet uses the admin_head
action hook to inject custom CSS into the WordPress admin area. It targets the category checklist container and increases its height to 300px, which can be adjusted as needed.
<?php
function increase_category_checklist_height() {
echo '<style>
#categorychecklist,
#category-all,
.categorydiv .tabs-panel {
max-height: 300px !important;
overflow-y: auto !important;
}
</style>';
}
add_action('admin_head', 'increase_category_checklist_height');
?>
How to Add via functions.php
or a Small Plugin
- Open your active theme’s
functions.php
file via Appearance > Theme Editor or FTP. - Paste the above PHP snippet at the end of the file.
- Save the file.
- Alternatively: Create a small plugin by creating a new PHP file (e.g.,
increase-category-height.php
) inwp-content/plugins/
with the following content:
<?php
/*
Plugin Name: Increase Category Checklist Height
Description: Dynamically increases the category checklist height in the WordPress admin post editor.
Version: 1.0
Author: Your Name
*/
function increase_category_checklist_height() {
echo '<style>
#categorychecklist,
#category-all,
.categorydiv .tabs-panel {
max-height: 300px !important;
overflow-y: auto !important;
}
</style>';
}
add_action('admin_head', 'increase_category_checklist_height');
?>
- Activate the plugin via WordPress admin > Plugins.
Step-by-Step Test
- Ensure you have multiple categories (20+). Add more if necessary via Posts > Categories.
- Edit or create a new post.
- Locate the Categories meta box on the right side.
- Verify that the category checklist height is increased (around 300px) and scrollable if needed.
- Try selecting multiple categories to confirm usability improvements.
- If the height is not applied, clear your browser cache and refresh the admin page.
Block Themes & Gutenberg Notes
In the Gutenberg (block) editor, the categories meta box is rendered differently, but the checklist container still uses similar CSS classes. The above CSS targets the classic category checklist and works in Gutenberg as well.
For block themes or full site editing, the categories panel height can still be controlled with this CSS injection. However, if you use custom block-based category selectors or third-party plugins, you may need to adjust the CSS selectors accordingly.
Common Pitfalls
- CSS specificity: If other plugins or themes override the category checklist styles with higher specificity, your changes might not apply. Use browser developer tools to inspect and adjust selectors if needed.
- Cache issues: Admin caching or browser cache can prevent immediate visibility of changes. Clear caches after adding the code.
- Incorrect placement: Adding the snippet outside PHP tags or in the wrong file can cause errors. Always add inside
<?php ?>
tags. - Plugin conflicts: Some admin UI plugins may replace or heavily customize the category meta box, requiring custom CSS targeting their markup.
Works on
Environment | Compatibility |
---|---|
Web Servers | Apache, Nginx, LiteSpeed (no server config needed) |
Control Panels | cPanel, Plesk, DirectAdmin |
WordPress Versions | 5.0 and above (Classic & Gutenberg editors) |
Themes | Classic themes, Block themes |
FAQ
-
Q: Can I increase the height beyond 300px?
A: Yes, simply change themax-height
value in the CSS to your preferred height (e.g., 400px or 500px). -
Q: Will this affect the category checklist on other admin pages?
A: The CSS targets the category checklist by ID and class used primarily on post edit screens. It should not affect other admin pages. -
Q: Does this work with custom taxonomies?
A: This snippet targets the default categories taxonomy. For custom taxonomies, you may need to adjust the CSS selectors to match their meta box IDs or classes.