Remove the Category Counts in the LearnDash Course List Category Dropdown

Written by Dan Mossop

In LearnDash, you might notice that each category in the Course List category dropdown shows a figure in brackets indicating the number of courses within that category. This automatic feature may not suit every site, so here's how to remove the category count and achieve a cleaner dropdown presentation.

Note, if you're using the LearnDash Course List module added to Divi by the Divi LearnDash Kit, the solution presented below will also work for you.

The image below illustrates the dropdown appearance before removing the course counts, and another showing how it looks afterward.

Before

After

Removing the LearnDash Category Course Count using PHP

You can use the following code snippet to remove the course counts from both the standard LearnDash category dropdown and the Divi LearnDash Course List module dropdown. This solution leverages a WordPress filter within LearnDash to alter the default output.

add_filter('ld_course_categorydropdown', 'remove_category_count_from_course_dropdown', 10, 3);

function remove_category_count_from_course_dropdown($ld_categorydropdown, $atts, $filter) {
    $ld_categorydropdown = preg_replace('/<option([^>]*?)>([^<]*?) \(\d+\)<\/option>/', '<option$1>$2</option>', $ld_categorydropdown);
    return $ld_categorydropdown;
}

Applying the Code

To implement this change, you have a couple of options:

  1. Child Theme: Add the above code snippet to the functions.php file of your child theme. This method is beneficial if you're comfortable modifying theme files and want to maintain changes when themes update.
  2. Plugin Approach: Alternatively, you can use a plugin like Code Snippets to add this functionality without directly editing theme files. This plugin provides a user-friendly interface for managing custom code snippets, making it a safer option for many site owners.

Conclusion

Adjusting the appearance of the category dropdown in your LearnDash course list or Divi LearnDash Course List module is a straightforward task that can enhance your site's aesthetics and usability. Whether you choose to make these tweaks through your child theme or a plugin, the change helps provide a cleaner interface for your learners. Tailoring your LearnDash setup to better meet your needs ensures a streamlined and user-friendly experience for everyone involved.

We may earn a commission when you visit links on our website.

Seamlessly Integrate LearnDash with Divi!

Elevate your LearnDash LMS with the Divi LearnDash Kit from Divi Booster. This plugin adds custom LearnDash modules to Divi, resolves compatibility issues, and supports Divi design settings, creating a cohesive and visually appealing learning environment.

Latest Posts

Customize Lightbox Title Styling in the Divi Gallery Module

Adjust the appearance of the lightbox title that appears when visitors open images from a Divi Gallery to align with your brand and improve readability. Refining the title’s color, size, and weight enhances visual hierarchy, accessibility, and overall polish. In this...

Center the Lightbox Image Count in the Divi Gallery Module

Centering the image count in a gallery lightbox creates a cleaner, more balanced presentation and makes it easier for visitors to see where they are in the image set. This simple visual tweak can enhance readability, especially with larger images and longer captions,...

Style the Divi Gallery Module Lightbox Image Count

Tailor the appearance of the image counter in the Divi Gallery module lightbox to match your brand and improve readability. By customizing the counter’s color and typography, you ensure it displays clearly and suits your design. In this guide we show you how to style...

Customize the Lightbox Image Background Color in the Divi Gallery

Control the color that appears behind your images when users open in the gallery lightbox, including support for semi-transparent hues. This helps improve contrast for transparent images, align the experience with your brand palette, and create a more polished viewing...

Style the Divi Gallery Lightbox Close Button

Give your gallery lightbox a clear, on-brand close button by customizing its color and size. This improves visibility and usability against varying image backgrounds and ensures the button renders at full opacity for a consistent experience. In this guide we show you...

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.