LLMS_Shortcodes::related_courses( array $atts )
Courses shortcode
Description Description
Used for [lifterlms_related_courses].
Parameters Parameters
- $atts
-
(array) (Required) Associative array of shortcode attributes.
Return Return
(array)
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;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| unknown | Introduced. |