Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Tag: Categories

Increasing The Categories Selection Height Dynamically In WordPress Admin

Posted on August 19, 2025 By Admin No Comments on 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

  1. Add a small PHP snippet to your theme’s functions.php file or a custom plugin.
  2. Use admin CSS to increase the height of the category checklist container.
  3. 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

  1. Open your active theme’s functions.php file via Appearance > Theme Editor or FTP.
  2. Paste the above PHP snippet at the end of the file.
  3. Save the file.
  4. Alternatively: Create a small plugin by creating a new PHP file (e.g., increase-category-height.php) in wp-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');
?>
  1. Activate the plugin via WordPress admin > Plugins.

Step-by-Step Test

  1. Ensure you have multiple categories (20+). Add more if necessary via Posts > Categories.
  2. Edit or create a new post.
  3. Locate the Categories meta box on the right side.
  4. Verify that the category checklist height is increased (around 300px) and scrollable if needed.
  5. Try selecting multiple categories to confirm usability improvements.
  6. 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

  1. Q: Can I increase the height beyond 300px?
    A: Yes, simply change the max-height value in the CSS to your preferred height (e.g., 400px or 500px).
  2. 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.
  3. 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.
…
WordPress Snippets

WooCommerce: Create tiered shipping by product category

Posted on August 19, 2025August 19, 2025 By Admin No Comments on WooCommerce: Create tiered shipping by product category

WooCommerce: Create Tiered Shipping by Product Category

If you run a WooCommerce store, you might want to charge different shipping rates based on product categories. For example, electronics might have a different shipping cost than clothing, or you might want to offer tiered shipping rates depending on the category and order quantity. WooCommerce doesn’t provide tiered shipping by category out of the box, but with a few simple steps, you can set this up quickly.

Quick Fix: Use Shipping Classes and Shipping Zones with Rules

  1. Create shipping classes corresponding to your product categories.
  2. Assign these shipping classes to products in each category.
  3. Set up shipping zones and add flat rate shipping methods.
  4. Configure tiered shipping costs per shipping class using cost formulas.

This approach leverages WooCommerce’s built-in shipping classes and flat rate shipping method cost formulas to simulate tiered shipping by product category without custom coding.

Why This Happens

WooCommerce’s default shipping system calculates shipping costs based on shipping zones and methods. Shipping classes allow grouping products for shipping cost differentiation, but WooCommerce does not natively support tiered or quantity-based shipping rates by category. By assigning shipping classes that mirror categories and using cost formulas, you can create tiered shipping rates that vary by category and quantity.

This method works because the flat rate shipping method supports cost formulas using placeholders like [qty] (quantity of items) and [cost] (base cost). By combining these with shipping classes, you can create tiered costs per category.

Step-by-step: Create Tiered Shipping by Product Category

  1. Create Shipping Classes
    • Go to WooCommerce > Settings > Shipping > Shipping classes.
    • Click Add shipping class for each product category you want to tier. For example:
      • Electronics
      • Clothing
      • Books
    • Save shipping classes.
  2. Assign Shipping Classes to Products
    • Go to Products > All Products.
    • Edit each product and assign the appropriate shipping class under the Shipping tab.
    • Update products.
  3. Set Up Shipping Zones
    • Go to WooCommerce > Settings > Shipping > Shipping zones.
    • Create or edit a shipping zone that applies to your customers (e.g., United States).
    • Add a Flat rate shipping method to this zone.
  4. Configure Tiered Shipping Costs Per Shipping Class
    • Click Edit on the flat rate shipping method.
    • Set the Cost field for the base rate (e.g., 5 for $5 base shipping).
    • Expand the Shipping class costs section.
    • For each shipping class, enter a cost formula that applies tiered rates. For example:
      • Electronics: 10 + ([qty] - 1) * 3 (first item $10, each additional $3)
      • Clothing: 5 + ([qty] - 1) * 1.5 (first item $5, each additional $1.50)
      • Books: 3 + ([qty] - 1) * 1 (first item $3, each additional $1)
    • Save changes.
  5. Test Your Setup
    • Add products from different categories to your cart.
    • Verify the shipping cost updates according to your tiered rules.

Edge Cases and Additional Tips

  • Multiple Categories per Product: WooCommerce shipping classes are single-select, so if a product belongs to multiple categories, assign the shipping class that best fits your shipping cost strategy.
  • Combining Shipping Classes: WooCommerce sums shipping class costs by default, so if your cart contains multiple classes, the total shipping cost will be the sum of each class’s tiered cost.
  • Free Shipping Thresholds: To offer free shipping for certain categories or order totals, add a Free shipping method to your shipping zone with conditions.
  • Using Plugins: For more complex tiered shipping rules (e.g., weight, volume, or mixed conditions), consider plugins like Table Rate Shipping or Advanced Shipping Packages.

Works On

Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Control Panels cPanel, Plesk, DirectAdmin
WooCommerce Versions WooCommerce 3.0 and above
WordPress Versions WordPress 5.0 and above

FAQ

  1. Can I set different tiered shipping rates for multiple categories in one order?

    Yes. WooCommerce sums the shipping costs for each shipping class in the cart, so tiered rates per category will combine automatically.

  2. What if a product belongs to multiple categories?

    Since shipping classes are single-select, assign the shipping class that best matches the shipping cost. For complex cases, consider plugins that support multiple shipping classes or custom rules.

  3. Can I use weight or dimensions in tiered shipping calculations?

    Not with the default flat rate method. For weight or dimension-based tiered shipping, use advanced shipping plugins like Table Rate Shipping.

…
WooCommerce How‑tos

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme

    Also by the maker of MySurveyReviews.com