# LearnDash: "Resume Course" Button Shortcode

> Adds a [wpide_ld_resume course_id="123"] shortcode that takes students straight to the first lesson or topic they have not finished yet.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: learndash, courses, shortcode
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/learndash-resume-course-button/

## Code

```php
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
    return;
}

add_shortcode( 'wpide_ld_resume', function ( $atts ) {
    $atts      = shortcode_atts( array( 'course_id' => 0, 'label' => 'Resume course' ), $atts, 'wpide_ld_resume' );
    $user_id   = get_current_user_id();
    $course_id = $atts['course_id'] ? absint( $atts['course_id'] ) : (int) learndash_get_course_id( get_the_ID() );

    if ( ! $user_id || ! $course_id || ! sfwd_lms_has_access( $course_id, $user_id ) ) {
        return '';
    }

    $url = get_permalink( $course_id );

    if ( function_exists( 'learndash_user_progress_get_first_incomplete_step' ) ) {
        $step = (int) learndash_user_progress_get_first_incomplete_step( $user_id, $course_id );

        if ( $step && get_post_status( $step ) ) {
            $url = function_exists( 'learndash_get_step_permalink' ) ? learndash_get_step_permalink( $step, $course_id ) : get_permalink( $step );
        }
    }

    return '<a class="wpide-ld-resume wp-element-button" href="' . esc_url( $url ) . '">' . esc_html( $atts['label'] ) . '</a>';
} );
```

## Notes

Falls back to the course page when every step is done or the next step cannot be found.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LearnDash: "Resume Course" Button Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
