A LearnDash community member asked how to display course pricing on an Elementor-built course site. This tutorial provides a free code snippet using WordPress shortcodes and LearnDash functions to accomplish this.

Step #1: Add the following snippet

add_shortcode( 'lmscoder-course-price', 'lmscoder_course_price' );
function lmscoder_course_price( $atts ) {
	// go away if LearnDash isn't active
	if ( ! function_exists( 'learndash_get_course_meta_setting' ) ) {
		return;
	}

	// go away if no ID is set in the shortcode
	if ( ! $atts['id'] ) {
		return;
	}

	// Since there is an ID set, make sure the ID is a nice and whole integer
	$id = intval( $atts['id'] );

	// get the price
	$price = learndash_get_course_meta_setting( $id, 'course_price' );

	// return the price
    return $price;
}

This uses the WordPress add_shortcode function and LearnDash’s learndash_get_course_meta_setting function to retrieve pricing data.

Step #2: Use the shortcode wherever you use shortcodes

The shortcode format is: [lmscoder-course-price id="29790"]

Replace the ID number with your specific course ID from LearnDash course settings.

Step #3: Keep these miscellaneous thoughts in mind

  • This pulls from the LearnDash price setting specifically
  • Works across multiple access modes
  • Consider using external ecommerce platform prices if that’s where sales are processed
  • For more complex requirements, custom development may be needed