# LearnDash: Certificate Download Button Shortcode

> Adds a [wpide_ld_certificate course_id="123"] shortcode that shows a "Download your certificate" button once the student has completed the course, and nothing before that.

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

## Code

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

add_shortcode( 'wpide_ld_certificate', function ( $atts ) {
    $atts      = shortcode_atts( array( 'course_id' => 0, 'label' => 'Download your certificate' ), $atts, 'wpide_ld_certificate' );
    $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 ) {
        return '';
    }

    $link = learndash_get_course_certificate_link( $course_id, $user_id );

    if ( ! $link ) {
        return '';
    }

    return '<a class="wpide-ld-certificate wp-element-button" href="' . esc_url( $link ) . '" target="_blank" rel="noopener">' . esc_html( $atts['label'] ) . '</a>';
} );
```

## Notes

Inside a course or lesson the course_id can be left out. Change the button text with label="...".

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LearnDash: Certificate Download 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/
