---
title: "Course Grid 2.0 Templating"
source: "https://docs.nexcess.com/software/learndash/course-grid-templating/"
description: "LearnDash Course Grid (CG) 2.0 is a brand new plugin written from scratch. It supports custom templating to make it easier for users to customize the template.…"
vertical: "Software"
area: "LearnDash"
date: "2021-11-18"
last_modified: "2026-07-02"
---

# Course Grid 2.0 Templating

LearnDash Course Grid (CG) 2.0 is a brand new plugin written from scratch. It supports custom templating to make it easier for users to customize the template. All the front-end aspects of the plugin including skins, cards, filter, and pagination are customizable.**NOTE** This documentation is regarding templating the Course Grid Add-on, if you want to learn more about using the actual add on and it’s features, check out our [Course Grid Add-on documentation](https://docs.nexcess.com/software/learndash/course-grid/).

## Skin

 Skin in Course Grid 2.0 is an object that defines the whole course grid style. The Skin templates folder is located in `/templates/skins/`. By default there are 4 different types of skins: grid, masonry, list, and legacy-v1. The first three skins are available to choose from in the Course Grid Gutenberg block while the legacy-v1 skin is specific to support CG 1.0 shortcodes. Each skin folder can have the following files:1. `layout.php` (mandatory) : define skin HTML layout
2. `style.css` (optional) : define skin CSS styles
3. `script.js` (optional) : define skin javascript file
 
 In layout.php, there are 2 available variables:1. `$posts` Array of `WP_Post` objects which are the query results of the course grid
2. `$atts learndash_course_grid` shortcode attributes
 
 In layout.php, users can use the helper function `<span style="font-weight: 400">learndash_course_grid_load_card_template( $shortcode_atts, $post )</span>` to load the skins card template automatically. To add a custom skin, users can follow the steps below:- Create a folder named with a unique skin slug in their active theme folder in the following path:` /learndash/course-grid/skins/` . For example if a user uses the Kadence theme, they can create a new folder like this: `wp-content/themes/kadence/learndash/course-grid/skins/custom-skin-slug/` .
 
 `layout.php` example: ```
<span style="font-weight: 400"><?php</span>
<span style="font-weight: 400">/**</span>
<span style="font-weight: 400">* Available variables:</span>
<span style="font-weight: 400">*</span>
<span style="font-weight: 400">* $posts  Array of WP_Post objects, result of the WP_Query->get_posts()</span>
<span style="font-weight: 400">* $atts  Shortcode/Block editor attributes that call this template</span>
<span style="font-weight: 400">*/</span>
<span style="font-weight: 400">?></span>
<span style="font-weight: 400"><</span><span style="font-weight: 400">div</span> <span style="font-weight: 400">class</span><span style="font-weight: 400">=</span><span style="font-weight: 400">"items-wrapper </span><span style="font-weight: 400"><?php</span> <span style="font-weight: 400">echo</span> <span style="font-weight: 400">esc_attr</span><span style="font-weight: 400">( </span><span style="font-weight: 400">$atts</span><span style="font-weight: 400">[</span><span style="font-weight: 400">'skin'</span><span style="font-weight: 400">] ); </span><span style="font-weight: 400">?></span><span style="font-weight: 400">"</span><span style="font-weight: 400">></span>
<span style="font-weight: 400"></span><span style="font-weight: 400"><?php</span> <span style="font-weight: 400">foreach</span><span style="font-weight: 400"> ( </span><span style="font-weight: 400">$posts</span><span style="font-weight: 400"> as </span><span style="font-weight: 400">$post</span><span style="font-weight: 400"> ) : </span><span style="font-weight: 400">?></span>
<span style="font-weight: 400"></span><span style="font-weight: 400"><?php</span> <span style="font-weight: 400">learndash_course_grid_load_card_template</span><span style="font-weight: 400">( </span><span style="font-weight: 400">$atts</span><span style="font-weight: 400">, </span><span style="font-weight: 400">$post</span><span style="font-weight: 400"> ); </span><span style="font-weight: 400">?></span>
<span style="font-weight: 400"></span><span style="font-weight: 400"><?php</span> <span style="font-weight: 400">endforeach</span><span style="font-weight: 400">; </span><span style="font-weight: 400">?></span>
<span style="font-weight: 400"></</span><span style="font-weight: 400">div</span><span style="font-weight: 400">></span>
```

- Add the required` layout.php` file to the folder with the other optional files `style.css` and `script.js` if necessary.
- Add the following code to the active themes functions.php or a plugin:
 
 ```
<span style="font-weight: 400">add_filter</span><span style="font-weight: 400">( </span><span style="font-weight: 400">'learndash_course_grid_skins'</span><span style="font-weight: 400">, </span><span style="font-weight: 400">function</span><span style="font-weight: 400">( </span><span style="font-weight: 400">$skins</span><span style="font-weight: 400"> ) {</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">$skins</span><span style="font-weight: 400">[</span><span style="font-weight: 400">'custom-skin-slug'</span><span style="font-weight: 400">] = [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'slug'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'custom-skin-slug'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'label'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'Custom Skin'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">// Optional</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'script_dependencies'</span><span style="font-weight: 400"> => [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'dependency-slug'</span><span style="font-weight: 400"> => [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'url'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'https://script_url'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'version'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'1.0'</span>
<span style="font-weight: 400"> ]</span>
<span style="font-weight: 400"> ],</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">// Optional</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'style_dependencies'</span><span style="font-weight: 400"> => [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'dependency-slug'</span><span style="font-weight: 400"> => [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'url'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'https://style_url'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'version'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'1.0'</span>
<span style="font-weight: 400"> ]</span>
<span style="font-weight: 400"> ],</span>
<span style="font-weight: 400"> ];</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">return</span> <span style="font-weight: 400">$skins</span><span style="font-weight: 400">;</span>
<span style="font-weight: 400">} );</span>
```

## Card

 Card in Course Grid 2.0 is an object that defines how an individual card inside a skin looks. Each skin can has multiple different card designs. Card templates folder are located in `/templates/cards/`. By default there are 5 different cards: grid-1, grid-2, grid-3 (available for grid and masonry skin), list-1, list-2 (available for list skin). Each card folder can have the following files:1. `layout.php` (required) : defines card HTML layout.
2. `style.css` (optional) : defines card CSS stylesheet
 
 To create a custom card design, users can follow the following steps:1. Create a folder named with a unique card slug in their active theme folder in the following path: `/learndash/course-grid/cards/` . For example if a user uses the Kadence theme, they can create a new folder like this: `wp-content/themes/kadence/learndash/course-grid/cards/custom-card-slug/`
2. Add the required `layout.php` file to the folder with the other optional files `style.css`
3. Add the following code to the active themes functions.php or a plugin:
 
 ```
<span style="font-weight: 400">add_filter</span><span style="font-weight: 400">( </span><span style="font-weight: 400">'learndash_course_grid_cards'</span><span style="font-weight: 400">, </span><span style="font-weight: 400">function</span><span style="font-weight: 400">( </span><span style="font-weight: 400">$cards </span><span style="font-weight: 400">) {</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">$cards</span><span style="font-weight: 400">[</span><span style="font-weight: 400">'custom-card-slug'</span><span style="font-weight: 400">] = [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'label'</span><span style="font-weight: 400"> => </span><span style="font-weight: 400">'Custom Card'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">// Skins this card is available for</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'skins'</span><span style="font-weight: 400"> => [ </span><span style="font-weight: 400">'grid'</span><span style="font-weight: 400">, </span><span style="font-weight: 400">'custom-skin'</span><span style="font-weight: 400">, </span><span style="font-weight: 400">'etc'</span><span style="font-weight: 400"> ],</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">// CG elements exist in the card design, added elements will be available in CG Gutenberg block</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'elements'</span><span style="font-weight: 400"> => [</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'thumbnail'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'ribbon'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'content'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'title'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'description'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'meta'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">'button'</span><span style="font-weight: 400">,</span>
<span style="font-weight: 400"> ],</span>
<span style="font-weight: 400"> ];</span>
<span style="font-weight: 400"></span><span style="font-weight: 400">return</span> <span style="font-weight: 400">$cards</span><span style="font-weight: 400">;</span>
<span style="font-weight: 400">} );</span>
```

## Pagination

 Course Grid 2.0 comes with 2 default paginations: load more button and infinite scrolling. Pagination templates are located in `/templates/pagination/`.
