title: How to get the first topic in a lesson in learndash
body: <p>I want to retrieve the first topic in a lesson in learndash and redirect it through it. But for some reason am not sure how to do it. </p>
  
  <p>I checked the API and doesn't see any appropriate filter/hook for it. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>  function redirect_to_first_topic() {
  // We only want to do this for Topics. But the below code can be adapted to work for Lessons
  global $post;
  $post_id = $post-&gt;ID;
  
  if ( get_post_type( $post_id ) == 'sfwd-lessons' ) {
      $progress = learndash_get_course_progress( null, $post_id );
      $link = $progress['next'];
  
      $parent_lesson_id = learndash_get_setting( $post, 'topic' );
      $parent_lesson = get_post( $parent_lesson_id );
      var_dump($parent_lesson);
  }
  
  // Always return $link
  // return $link;
  
  }
  
  add_action('wp', 'redirect_to_first_topic');
  </code></pre>
  
  <p>So basically what am doing here is getting the parent which is the lesson. </p>