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

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts