LMS & eLearning

Add a LearnDash Certificate Download Button Anywhere

Use the [ld_certificate] shortcode to show a certificate download button on any page, in emails or in a dashboard: every attribute, how it decides eligibility, the banner style, and a PHP version for templates.

Add a LearnDash Certificate Download Button Anywhere

By default a learner finds their certificate link in two places: the alert at the top of a completed course and the certificate column in the profile shortcode. Sites usually want it elsewhere too, on a custom dashboard, a group page, a completion email or a "my certificates" page. The [ld_certificate] shortcode is the built-in way to put a LearnDash certificate download button anywhere, and it does the eligibility check for you, so it is safe to place on a page that learners reach before they finish.

This guide covers every attribute, how the shortcode picks its context, the banner display, and the PHP functions behind it for theme templates.

The shortcode

[ld_certificate course_id="123" label="Download your certificate" class="ld-button"]

Attributes:

  • course_id, quiz_id, group_id: which object's certificate to link. Give one of them. If you give none, the shortcode looks at the page it is on: a group page supplies the group, a quiz page the quiz, and a course, lesson or topic page supplies the course through learndash_get_course_id(). On any other page with no ID it prints nothing.
  • user_id: defaults to the current user. Administrators can set it to render another learner's button.
  • label: the button text, default "Certificate". Shortcodes inside the label are processed.
  • class: CSS class on the link, default button. id sets an HTML id.
  • display_as: button for a plain link, or banner for the LearnDash 3.0 theme's green success alert with a Download Certificate button. The banner falls back to a button on the legacy theme.
  • context and callback: internal hooks for themes; most sites never set them.

All attributes pass through the ld_certificate_shortcode_values filter before use, the final URL through ld_certificate_shortcode_cert_url, and the finished button markup through learndash_certificate_html, which receives the HTML, the attributes and the enclosed content.

How it decides whether to show

The shortcode outputs nothing unless the learner has earned the certificate, which makes it safe on shared pages. For a course it calls learndash_course_status() and only when that returns completed asks learndash_get_course_certificate_link() for the URL. For a group it asks learndash_get_group_certificate_link(), which returns empty until every course in the group is complete. For a quiz it reads learndash_certificate_details() for the certificate and threshold, walks the learner's attempts in order, and uses the first attempt whose percentage meets the threshold, adding that attempt's time to the URL so the PDF prints the matching score. The three conditions are explained in our comparison of course, quiz and group certificates.

Examples

On a thank-you or completion page that knows the course:

[ld_certificate course_id="123" display_as="banner"]

Inside a course's own content, where no ID is needed because the page supplies it:

[ld_certificate label="Download certificate"]

For a quiz certificate on the quiz page, where the shortcode picks the quiz up from context:

[ld_certificate display_as="button" label="Print your exam certificate" class="ld-button ld-button-transparent"]

A "my certificates" page listing several courses, one shortcode per course. Courses the learner has not finished print nothing, so the list only shows earned certificates:

<p>Safety Induction: [ld_certificate course_id="123" label="Download"]</p>
<p>Manual Handling: [ld_certificate course_id="124" label="Download"]</p>
<p>Fire Warden Programme: [ld_certificate group_id="77" label="Download"]</p>

For a dynamic list without hard-coded IDs, the profile shortcode [ld_profile] already shows a certificate link per completed course, and a developer can loop learndash_user_get_enrolled_courses() and call the shortcode per course.

In emails

Emails are rendered without a logged-in user, so [ld_certificate] in an email body needs user_id set to the recipient. The Notifications add-on does not have a certificate tag of its own, so for emails sent from a completion hook, build the URL with learndash_get_course_certificate_link( $course_id, $user_id ) and insert it as a normal link; our completion hooks reference shows where to send it from. Note that the link carries a nonce created for the viewing user, so a link generated inside a cron job or hook with no logged-in user is created with a viewer ID of zero and is valid for the learner only when they are logged in as themselves; see our article on how certificate links are secured for the details.

From PHP in a template

In a theme template or a custom dashboard, call the same functions the shortcode uses:

$user_id   = get_current_user_id();
$course_id = 123;

if ( 'completed' === learndash_course_status( $course_id, $user_id, true ) ) {
    $url = learndash_get_course_certificate_link( $course_id, $user_id );
    if ( $url ) {
        printf(
            '<a class="ld-button" target="_blank" href=%1$s>%2$s</a>',
            '"' . esc_url( $url ) . '"',
            esc_html__( 'Download certificate', 'your-textdomain' )
        );
    }
}

Or simply echo do_shortcode( '[ld_certificate course_id="123"]' );, which keeps the eligibility logic in one place. For groups use learndash_get_group_certificate_link(); for quizzes, learndash_certificate_details() plus the attempt walk shown above, or the shortcode.

Styling

The button is a plain anchor with your class, so theme button classes work. In the LearnDash 3.0 theme, ld-button gives the standard filled button and ld-button ld-button-transparent the outline version. The banner uses the theme's alert module and inherits its colours. Add target="_blank" behaviour through CSS or a small script if you want the PDF in a new tab; the plain button opens it in the same tab, while the banner's button opens a new one.

Troubleshooting

If the button does not appear for a learner who should have it, the shortcode is doing its job and the learner is not yet eligible, the certificate is not attached, or the page is cached for a logged-out state. Our guide to the certificate link not showing works through the checks in order.

When to get help

A button on a page is a shortcode. The projects that need a developer are dashboards listing every earned certificate with dates, certificate links delivered by a CRM or email platform, and buttons that generate a stored PDF for later verification. Our LearnDash services team builds those on the functions above, and a LearnDash developer can add a certificates panel to an existing member dashboard in a short engagement.

Frequently asked questions

Can I show the certificate button before the course is complete, greyed out?

Not with the shortcode, which prints nothing until the learner is eligible. Print your own disabled button in the else branch of the template code above.

Does the button work for group leaders viewing a learner?

Set user_id to the learner. The generated link includes a user parameter and a nonce tied to the viewing leader, so the leader can open the learner's PDF.

Why does the button show for a quiz the learner failed?

The certificate threshold is separate from the passing percentage, and an earlier attempt may have met it. Check the threshold on the quiz and the learner's attempt history.

Can the label contain an icon?

Yes. The label is passed through do_shortcode() and printed as HTML, so an icon shortcode or an inline SVG works.

Add WorldWin Coder to your preferred sources

Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.

· Developers and project managers

Articles written and reviewed by the developers and project managers at WorldWin Coder, who build and maintain websites, web applications and mobile apps on WordPress, Moodle, PHP, Laravel, CodeIgniter and Flutter.

Keep reading

Have something to build, fix or move?

Tell us where you are. A developer reads every inquiry, and you get next steps and a free quote within one business day.