Created
November 22, 2015 03:14
-
-
Save marcovega/d0eed9e0108c946ada96 to your computer and use it in GitHub Desktop.
Shortcode to list all lessons within a course in Woo Sensei
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* List lessons by course | |
* | |
* Generates the shortcode that outputs the list of the lessons for a given course. | |
* | |
* @return string The HTML Layout output of the Course Lessons. | |
*/ | |
function lessons_shortcode_func(){ | |
$args = [ | |
'post_type' => 'lesson', | |
'posts_per_page' => 99, | |
'orderby' => 'meta_value_num', | |
'meta_key' => '_order_51', | |
'order'=> 'ASC', | |
'meta_query' => [ | |
'key' => '_lesson_course', | |
'value' => '51' | |
] | |
]; | |
$lessons = get_posts( $args ); | |
$output = null; | |
foreach($lessons as $lesson){ | |
$output .= $lesson->post_title . '<br>'; | |
} | |
return $output; | |
} | |
add_shortcode( 'list-lessons', 'lessons_shortcode_func' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this