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.

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.

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 *.

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

Latest Posts

How to Hide a Divi Module When Scrolling Up or Down

In this quick tutorial, I’ll show you how to hide a Divi module when scrolling in a specific direction (up or down), so that the module only shows when you want it to. This is especially useful when using Divi’s Scroll Effects feature and you have a effect you want to...

Fade a Divi Image Module Edge into the Background

Want to create a stylish fade effect on your Divi image module—where one side fades smoothly into the background? With a bit of CSS, you can make any edge (or corner) of the image fade out: top, bottom, left, right, or even diagonally.Fade a Divi Image Module Edge...

Hide the Header and Footer in the Hello Elementor Theme

Removing the default header and footer from your Hello Elementor theme allows for a streamlined and distraction-free website design. This is especially useful when creating unique landing pages, full-width layouts, or custom headers and footers with a page builder. In...

Setting up the Divi Password Box Module

Setting up password protection on a page can help you control access to sensitive or private content in WordPress, allowing only authorized visitors to view certain sections. With the Divi Password Box module, you can replace the plain Divi password form with a fully...

Open Divi Social Media Icons in a New Tab

Ensuring your website's social media icons open in a new browser tab creates a seamless user experience and keeps visitors engaged with your site while allowing them to explore your social media presence. This approach prevents users from navigating away from your...