# LearnDash: "My Courses" List With Progress

> Adds a [wpide_ld_my_courses] shortcode that lists every course the student is enrolled in, with their progress and a Start, Continue or Review link.

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

## Code

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

add_shortcode( 'wpide_ld_my_courses', function () {
    $user_id = get_current_user_id();

    if ( ! $user_id ) {
        return '<p>Please <a href="' . esc_url( wp_login_url( get_permalink() ) ) . '">log in</a> to see your courses.</p>';
    }

    $course_ids = learndash_user_get_enrolled_courses( $user_id );

    if ( ! $course_ids ) {
        return '<p>You are not enrolled in any courses yet.</p>';
    }

    $courses = get_posts( array( 'post_type' => 'sfwd-courses', 'post__in' => array_map( 'intval', $course_ids ), 'numberposts' => count( $course_ids ), 'orderby' => 'title', 'order' => 'ASC', 'no_found_rows' => true ) );
    $html    = '<ul class="wpide-ld-my-courses" style="list-style:none;padding:0">';

    foreach ( $courses as $course ) {
        $progress = learndash_course_progress( array( 'user_id' => $user_id, 'course_id' => $course->ID, 'array' => true ) );
        $percent  = (int) ( $progress['percentage'] ?? 0 );
        $action   = $percent >= 100 ? 'Review' : ( $percent > 0 ? 'Continue' : 'Start' );

        $html .= sprintf(
            '<li style="display:flex;flex-wrap:wrap;justify-content:space-between;gap:.5em;padding:.75em 0;border-bottom:1px solid rgba(127,127,127,.25)"><span><strong>%1$s</strong> <small>%2$d%% complete</small></span><a href="%3$s">%4$s</a></li>',
            esc_html( get_the_title( $course ) ),
            $percent,
            esc_url( get_permalink( $course ) ),
            esc_html( $action )
        );
    }

    return $html . '</ul>';
} );
```

## Notes

Visitors who are not logged in see a login link. Courses are listed in alphabetical order.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LearnDash: "My Courses" List With Progress" 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/
