Additional Shortcodes for LearnDash – Course Grid Shortcode
LearnDash Courses Grid Shortcode #
This shortcode displays LearnDash courses in different styles depending on the templates, as well as with different extra functionalities.
It can take multiple parameters, as follows:
- template: a number between 1 and 6 to define the style corresponding to an EA template. e.g template=”1″
- columns: the number of columns to display the courses. This only applies to some templates, it can be a number between 1 and 4. Also, this only applies to desktops, the grid will only have 1-2 columns on mobile and tablets regardless of this parameter. e.g columns=”4″
- posts_per_page: How many courses can it show at a time before requesting more? This only applies to template 6 at the moment, since is the only one that has a “more courses” button that reloads the following courses (like Ajax pagination basically). e.g posts_per_page=”5″
- featured_courses: a parameter that makes the grid, instead of showing all courses, just show courses with the meta field “featured”. Also, template 1 changes the styling. e.g. featured_courses=”true”
Extra Meta Fields Created #
- product_id: This plugin now automatically adds a product_id meta to a course. It is saved when a user creates/updates a Woocommerce product with an associated course. For now, it only works with the FIRST associated course. If a course has a product_id pointing to a correct WC product, then the price of that product will be used on the course grid to show the price of the course. If not, then it will show the price of the course in the Learndash course settings.
- featured: this meta is used to simply point out that is a course the user wants to showcase more than others. This meta is checked when the featured_courses parameter of the shortcode is used.
- instructor_id: this meta is used when a course card needs to show the instructor of a course. The value should be the id of a current user.
- course_start_date: course cards in template 4 show the start date for a course. Instead of doing something complicated, we just have a meta field called course_start_date that is a String.
How are ratings shown?
First, it will see if the Course Reviews for LearnDash plugin is active, if so then it will show the average rating for a course. If the plugin is not active, it will try to show the average rating of the associated Woocommerce product of the course (i.e product_id meta field).
How are prices shown?
First, it will see if the LearnDash course has a valid ‘product_id’ meta field, meaning a valid associated WooCommerce product. If so, it will assume the user uses the WooCommerce product to sell the course, therefore the real price is the one from the product. In that case, it will show the price of the associated product, if not then simply show the price in the settings of the LearnDash course
[ea_ld_course_grid template="1" featured_courses="true"]
Mini-Course Grid Shortcode #
This shortcode displays this list of courses in a small vertical format.
- template: (1 – 6)