Reputation: 445
I try to customize the course content list forming by the LearnDash plugin. Now on the lesson page in the sidebar displays just a boring list of the lessons included in the course (the current shortcode formed it). But I need to display the list of the lessons with thumbnails and other meta information from the lessons. For this purpose, I try to use this chunk of code:
<?php
$args = array(
'cat' => 153,
'post_type' => 'sfwd-courses',
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page' => -1,
'post_status' => 'publish');
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="timeline">
<h3><?php the_title(); ?></h3>
<?php endwhile; else: ?>
<?php _e('No Posts Sorry.'); ?>
<?php endif; ?>
</div>
And I always see the same answer: "No Posts Sorry". Please help to sort out this issue.
Upvotes: 0
Views: 1081
Reputation: 49
Please try below code which helps you to display lessons fo specific category.
<?php
$args = array(
'post_type' => 'sfwd-lessons',
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'ld_lesson_category', //double check your taxonomy name in you db
'field' => 'id',
'terms' => 26,
),
),
);
$q = new WP_Query($args); ?>
<div class="timeline"> <?php
if ($q->have_posts()) : while ($q->have_posts()) : $q->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php endwhile; else: ?>
<?php _e('No Posts Sorry.'); ?>
<?php endif; ?>
</div>
Upvotes: 1