Display a Custom Post Type within another with hierarchically slug

Base on comment, you need to create a little function to display these related posts. You can do it in different ways, here is an simple example by adding your own action to the template.

in your template file place where you want to show related lessons

do_action('related_lesson');

In functions.php

function get_related_lesson(){
    global $post;

    $args = array(
              'post_type'=>'lesson',
              'posts_per_page' => 6,
              'post_status'=> 'publish',
              'meta_query' => array(
                  array(
                    'key'     => 'course_id',
                    'value'   => $post->ID,
                    'compare' => 'LIKE',
                 ),
              )
    );
    $related_posts = new WP_Query($args);

    while ( $related_posts->have_posts() ) {
       $related_posts->the_post();
       echo '<li><a href="' .get_permalink($related_posts->post->ID). '">' . get_the_title( $related_posts->post->ID ) . '</a></li>';
    }

    // Restore original Post Data
    wp_reset_postdata();
}
add_action('related_lesson', 'get_related_lesson');

You can also use the_content filter.

Hope it helps.

tech