How do I get a list of 'Lesson' IDs from a 'Course' ID
-
AuthorPosts
-
-
July 19, 2019 at 12:57 AM #460288Elliott ManghamParticipant
Hello,
If I have a ‘Course’ ID, for example, “123”, how can I get a list of ‘Lesson’ IDs associated with that particular course in PHP?
I want to do something like this (FOR EXAMPLE):
$course_id = 123; $lessons_in_course = get_lessons_as_id( $course_id ); foreach( $lessons_in_course as $lesson ) { ... }
I cannot seem to find where this data is stored/located at all.
Thank you so much!
-
July 19, 2019 at 10:38 AM #460416AnonymousInactive
Dear Elliott Mangham,
Please let me know why you need to get a list of ‘Lesson’ IDs from a ‘Course’ ID
Best regards,
Huyen Anh
-
July 19, 2019 at 1:11 PM #460442Elliott ManghamParticipant
Hi,
Why does it matter why I need to do it? I’m creating a custom theme and need to list each lesson related to a specific course, with PHP. This way, I can also pull in additional data related to each lesson, such as ACF data, for example…
Thanks.
-
-
July 19, 2019 at 1:14 PM #460443AnonymousInactive
Dear Elliott Mangham,
I’m so sorry.
Can you say more clearly about where you want to show a list of ‘Lesson’ IDs from a ‘Course’ ID?
Because with this, you only need go to Course, you’ll see the list of lesson in that course.
Best regards,
Huyen Anh
-
July 19, 2019 at 1:17 PM #460444Elliott ManghamParticipant
Hi again,
I am creating a CUSTOM THEME and as part of the requirement for this specific project, I need to display a list of lesson data related to a specific course, in a different area of the site, with different code. I understand there’s a pre-built list on a Course page, but this isn’t what I need.
Is there not some sort of function I can utilise, i.e. get_lessons_in_course( $course_id )?
Thanks.
-
-
July 19, 2019 at 1:27 PM #460450AnonymousInactive
Dear Elliott Mangham,
Please try to use this function: learn_press_get_course_curriculum
Best regards,
Huyen Anh
-
July 19, 2019 at 1:45 PM #460457Elliott ManghamParticipant
Hi,
This appears to have the data I need, but when I attempt to create a loop from the data, I get an error
Fatal error: Uncaught Error: Cannot access protected property LP_Course_Section::$items
.The data within the function is protected
[items:protected]
.Any suggestions? Thanks
-
-
July 19, 2019 at 1:51 PM #460458AnonymousInactive
Dear Elliott Mangham,
With this, you should find a developer they’ll help you write a query to get lesson from database.
Best regards,
Huyen Anh
-
July 19, 2019 at 1:55 PM #460461Elliott ManghamParticipant
Hi,
What about by listing the lessons using
query_posts()
and somehow filtering them by course?There is no documentation on this…
Thanks,
-
-
July 19, 2019 at 1:59 PM #460467AnonymousInactive
Dear Elliott Mangham,
I’m so sorry. We don’t have the documentation about this.
With this, you should find a developer. They will help you.
Or you can research it for yourself.
Thanks!
Best regards,
Huyen Anh
-
July 19, 2019 at 2:02 PM #460470Elliott ManghamParticipant
I am a developer, but the plugin offers absolutely no technical documentation making the plugin redundant without using a pre-built theme.
Thanks for your time.
-
-
July 19, 2019 at 2:06 PM #460473AnonymousInactive
Dear Elliott Mangham,
I’m so sorry about that but all plugins on WordPress don’t have the documentation about code.
So if you’re a developer, you should research about it for your self. Please try search it.
Hope you understand.
Best regards,
Huyen Anh
-
July 19, 2019 at 2:21 PM #460480Elliott ManghamParticipant
Hi,
A) Plugins do normally come with technical documentation, as well as accessible hooks to utilise. Especially when there’s a mass of data generated by said plugin, and B) I have searched it – but no documentation specifically for LearnPress.
I will write up a solution myself and share the solution with others for future reference. I was hoping the developers would have put functions in-place already.
Again, I really appreciate your time.
-
-
July 19, 2019 at 2:30 PM #460482AnonymousInactive
Dear Elliott Mangham,
Please try to use this:
$course->get_items( LP_LESSON_CPT );
Best regards,
Huyen Anh
-
July 19, 2019 at 2:39 PM #460484Elliott ManghamParticipant
Hi,
This fires an error:
Fatal error: Uncaught Error: Call to undefined method WP_Post::get_items()
This is definitely the type of thing I was looking for though! (one that works)
Thanks
-
-
July 19, 2019 at 2:44 PM #460488AnonymousInactive
Dear Elliott Mangham,
Note: $course is an object of COURSE
Exp: $course = learn_press_get_course(ID_OF_COURSE)
ID_OF_COURSE is ID of the post with post_type is lp_course
Best regards,
Huyen Anh
-
July 19, 2019 at 3:24 PM #460508Elliott ManghamParticipant
Oops, it’s because I was using
lp_course
instead oflp_lesson
as the post type, but I’m glad you thought the same!This works an absolute dream, thank you!
Do you have a list of these helpful functions anywhere to use as a reference point? No doubt, I’ll need to some something similar for other data at some point in the near future :-)
Really appreciate the help +++++
-
July 19, 2019 at 3:27 PM #460510AnonymousInactive
Dear Elliott Mangham,
I’m so sorry.
We don’t have the list of these function. But thanks for your feedback, we’ll consider and add it in the documentation.
I hope you were satisfied with our plugin as well as the level of service we provided. If you are happy with the plugin & our services, please consider to rate 5 stars for our plugin here: https://wordpress.org/support/plugin/learnpress/reviews/?rate=5#new-post
You may need to create an account here: https://login.wordpress.org/
I very appreciate your help.
If you need any assistance about our LMS items, please let me know.
Best regards,
Huyen Anh
-
-
AuthorPosts
You must be logged in to reply to this topic. You can click here