Adding a Search and Filter Bar With [learndash_course_grid_filter]
How the Course Grid filter bar works: the built-in toggle, the standalone filter shortcode and block, the keyword, taxonomy and price controls, how each is applied over AJAX, and how to place the bar in a sidebar.
![Adding a Search and Filter Bar With [learndash_course_grid_filter]](/uploads/2026/10/adding-search-filter-bar-learndash-course-grid-filter-bf229f2b.webp)
A catalog with more than a dozen courses needs a way to narrow it down. Course Grid 2 ships a filter bar with a keyword search, taxonomy checkboxes and a price range, applied without reloading the page. It appears in two forms: a toggle built into the grid, and a standalone shortcode and block you can place anywhere on the page and point at a grid. Both render the same template and send the same request, so the choice is about layout.
This guide explains the LearnDash course grid filter in version 2.0.9: what each control does, how the request is processed, the attributes on both the grid and the filter shortcode, and the limits to know before you promise a client faceted search.
The built-in toggle
Every grid has filter="true" by default. The grid renders a Filter button above the cards, and clicking it reveals the filter bar, which the grid builds by calling the filter shortcode internally with the grid's id and its five filter attributes: filter_search, filter_taxonomies, filter_price, filter_price_min and filter_price_max. The grid's own taxonomies attribute is passed as the defaults, so terms already applied to the grid appear pre-checked and disabled in the bar.
Out of the box the bar contains the keyword field and the price range and no taxonomy checkboxes, because filter_taxonomies is empty. The first configuration step on most sites is therefore:
[learndash_course_grid id="catalog" filter_taxonomies="ld_course_category, ld_course_tag" filter_price_max="500"]
The standalone shortcode and block
To place the bar in a sidebar, above a hero, or in its own column, set filter="false" on the grid and add the filter separately:
[learndash_course_grid_filter course_grid_id="catalog" search="true" taxonomies="ld_course_category" price="true" price_min="0" price_max="500"]
The course_grid_id is required and must match the grid's id; without it the shortcode prints "Missing course_grid_id attribute." The block version, LearnDash Course Grid Filter, has a Course Grid ID field for the same purpose. The standalone defaults differ slightly from the grid's: taxonomies defaults to category, post_tag rather than empty. The filter attaches to the grid through the id, so the two can be anywhere on the same page. The default attributes are filterable with learndash_course_grid_filter_default_shortcode_attributes.
What each control does
Keyword
The keyword is sent as the query's search parameter, so it matches titles and content the way WordPress search does, not the course grid short description. It is applied on Apply, not as you type.
Taxonomy checkboxes
For each taxonomy named in the attribute, the template prints a checkbox per term, including empty terms, ordered by name. Checked terms are sent by term ID and become a taxonomy query. Terms within a taxonomy match with OR, and when more than one taxonomy is used the taxonomies also combine with OR, so a course in the chosen category or with the chosen tag matches. There is no AND mode in 2.0.9. Terms fixed by the grid's own taxonomies attribute appear checked and disabled, which tells visitors the grid is already narrowed.
Price range
The price section shows two sliders and two number fields for minimum and maximum. The range is split in half between the sliders, with a step calculated from the range, so a maximum of 1,000 gives steps of 50. Prices are compared after the query: because course prices live in LearnDash settings rather than a sortable meta field, the plugin fetches all matching courses, reads each one's price and keeps those within range, then paginates the result in memory. A maximum of 0 keeps free courses. The price filter is only applied to courses and groups; for other post types it does nothing. Our guide to prices on course grid cards explains where the price comes from.
How the request is processed
Apply sends an AJAX request to the ld_cg_apply_filter action with a nonce, the grid's attributes as JSON and the filter values. The server rebuilds the grid query from the attributes, adds the keyword and taxonomy conditions, runs the learndash_course_grid_query_args filter with the filter values as its third argument, applies the price comparison if needed, renders the first page of cards with the same card template and returns the HTML and the next page number. Clear resets the controls and reloads the unfiltered first page. Load More and infinite scroll keep the active filter, because the same values are sent with each page request.
Because the request goes through admin-ajax, it works on cached pages. The nonce is generated when the page renders, so a page cached for longer than the nonce lifetime, roughly a day, returns an error on Apply. Shorter cache lifetimes or excluding the catalog from the page cache both fix it; see how WordPress caching works.
Styling and placement
The bar renders inside a learndash-course-grid-filter wrapper with sections for search, taxonomies and price and Apply and Clear buttons, styled by the plugin's filter stylesheet, which depends on Dashicons. The template at templates/filter/layout.php can be overridden in the theme at learndash/course-grid/filter/layout.php if the markup needs to change, for example to render taxonomies as dropdowns; our guide to overriding course grid templates covers the mechanism. Hide the built-in toggle with filter="false" whenever you place the standalone bar, or visitors get two.
Limits to know
- No AND across taxonomies and no exclusion filters.
- No sort control for visitors; order is fixed by the grid.
- The keyword searches WordPress content, not the grid's short description or duration.
- The price filter loads every matching course before comparing, so a price-filtered request on a catalog of thousands of courses is slow.
- Filter state is not in the URL, so a filtered view cannot be bookmarked or shared.
Faceted search with counts, AND logic, URL state and sorting is a custom build on top of the grid's query filter or a search plugin. That is a common request from training providers with large catalogs and something our LearnDash services team scopes regularly; a LearnDash developer can extend the filter template and AJAX handler rather than replacing the grid. The basics of narrowing a grid without the bar are in filtering the course grid by category, tag, enrollment and progress.
Frequently asked questions
Why does the filter bar show no categories?
The grid's filter_taxonomies attribute is empty by default. Set it to the taxonomy names you want, such as ld_course_category. The standalone shortcode defaults to the post category and tag taxonomies, which courses usually do not use.
Can the filter bar control two grids?
No. It targets one grid by id. Place a second filter for the second grid.
Why are some checkboxes already ticked and greyed out?
Those terms are fixed by the grid's own taxonomies attribute. They show the visitor what the grid is already limited to and cannot be unticked.
Why does Apply return an error after a while?
The page was cached with a nonce that has since expired. Lower the cache lifetime for the catalog page or exclude it from page caching.
Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.
