Thread Starter
kskerp
(@kskerp)
Or perhaps you could explain to me how I could edit:
$next_lesson = $wpdb->get_row($wpdb->prepare(“SELECT tP.* FROM {$wpdb->posts} tP JOIN {$wpdb->postmeta} tM ON tM.post_id = tP.ID AND tM.meta_key = ‘namaste_course’ WHERE tP.post_type = ‘namaste_lesson’ AND tM.meta_value = %d AND tP.ID > %d AND tP.post_status = ‘publish'”, $course_id, $post->ID));
to grab the prior lesson if one existed instead of the alternate?
Plugin Author
Bob
(@prasunsen)
just change AND tP.ID > %d to AND tP.ID < %d
We’ll add the shortcode in the next release
Thread Starter
kskerp
(@kskerp)
awesome, thank you! It worked out Great!
I thought it would be a pretty similar addition.
Thread Starter
kskerp
(@kskerp)
By the way, it was not as simple as I originally thought. It was returning the “0” or first lesson in the course instead of the “oldest prior lesson” (so if you were on lesson 4, the prior lesson would be lesson 1, and if you were on lesson 8, the prior lesson would still be lesson 1). I have it working on my wordpress page now so that the prior lesson is the exact prior lesson of the current lesson.
I had to use a “$next_lesson_checker” and a while loop comparing it to the $post->ID to get it working properly. I imagine it would only take you a couple minutes, but I could email you it to save you some time possibly.
Thanks again for replying back to my original post, it let me understand what was happening in the method a whole lot easier 🙂
Plugin Author
Bob
(@prasunsen)
Oh yes, my mistake. You could actually achieve this by adding “ORDER BY tP.ID DESC” in the query. Anyway, we’ll have this shortcode added pretty soon.
Thread Starter
kskerp
(@kskerp)
haha by couple minutes I meant seconds 🙂