Get lesson id in the single lesson template
-
Hello, i need to get the current lesson id in the single lesson template because i need to use advanced custom field in the template and i need the id of the post but not of the coure, of the lesson. by default if i get post_id i get the id of the course but i need lesson post id.
content-item.php
<?php /** * Template for displaying item content in single course. * * This template can be overridden by copying it to yourtheme/learnpress/single-course/content-item.php. * * @author ThimPress * @package Learnpress/Templates * @version 3.1.0 */ /** * Prevent loading this file directly */ defined( 'ABSPATH' ) || exit(); global $post; $user = LP_Global::user(); $course_item = LP_Global::course_item(); $course = LP_Global::course(); $can_view_item = $user->can_view_item( $course_item->get_id(), $course->get_id() ); $block_by_check = $course_item->is_blocked_by( $user->get_id(), $course->get_id() ); $course_id = get_the_id(); $courseProva = learn_press_get_course( $course_id ); $curriculum = $courseProva->get_curriculum(); foreach ( $curriculum as $section ) { // Get the lessons associated with the section. $lessons = $section->get_items(); // Iterate over each lesson. foreach ( $lessons as $lesson ) { // Now you can work with each lesson, for example: // Get the lesson ID. $lesson_id = $lesson->get_id(); echo $lesson_id; echo '******'; } } ?>with this method i can get all lesson id of the course but i need the current.
anyone can help me?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Get lesson id in the single lesson template’ is closed to new replies.