LLMS_Shortcodes::related_courses( array $atts )

Courses shortcode


Description Description

Used for [lifterlms_related_courses].


Top ↑

Parameters Parameters

$atts

(array) (Required) Associative array of shortcode attributes.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/shortcodes/class.llms.shortcodes.php

	 */
	public static function related_courses( $atts ) {

		ob_start();

		if ( isset( $atts['category'] ) ) {
			$tax = array(
				array(
					'taxonomy' => 'course_cat',
					'field'    => 'slug',
					'terms'    => $atts['category'],
				),
			);
		}

		$query = new WP_Query(
			array(
				'post_type'      => 'course',
				'post_status'    => 'publish',
				'posts_per_page' => isset( $atts['per_page'] ) ? $atts['per_page'] : -1,
				'order'          => isset( $atts['order'] ) ? $atts['order'] : 'ASC',
				'orderby'        => isset( $atts['orderby'] ) ? $atts['orderby'] : 'title',
				'tax_query'      => isset( $tax ) ? $tax : '',
			)
		);

		if ( $query->have_posts() ) {

			lifterlms_course_loop_start();

			while ( $query->have_posts() ) :
				$query->the_post();

				llms_get_template_part( 'content', 'course' );

			endwhile;

			lifterlms_course_loop_end();

			$courses = ob_get_clean();
			wp_reset_postdata();
			return $courses;
		}



Top ↑

Changelog Changelog

Changelog
Version Description
unknown Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.