Add Enrol and Buy Buttons Anywhere With the Payment Buttons Shortcode
How to place a LearnDash enrol or buy button on any page with the payment buttons shortcode and block, what the button shows for each price type, and why it sometimes renders nothing at all.

The enrol button on a LearnDash course page is generated, not hand written. The same generator is exposed as the [learndash_payment_buttons] shortcode and the Payment Buttons block, so you can put a working Take this Course or Buy button on a landing page, in a sidebar, inside a pricing table or in a page builder module. This guide covers the attributes, what the button becomes for each price type, where it hides on purpose, and the filters that change its label or markup. Everything below is taken from LearnDash 4.18.0.1.
The shortcode and its attributes
The shortcode accepts two attributes, course_id and group_id. If you give neither, it works out the context from the page it sits on: on a course, lesson, topic or quiz it uses the course that step belongs to, and on a group page it uses that group. On an ordinary page it has nothing to go on and renders nothing, so always set an ID when the button lives outside the course itself.
[learndash_payment_buttons course_id="123"]
[learndash_payment_buttons group_id="456"]
The block version, found under the LearnDash category as Payment Buttons, exposes the same two settings in its sidebar and renders through the same code, so the output is identical whichever you use. Group buttons follow the same rules as course buttons, with the label reading Enroll in Group and the group's price settings supplying the price.
What the button shows for each price type
The shortcode calls the same function the course template calls, learndash_payment_buttons(), which hands the post to a button class that decides what to output from the product's price type and the current user's situation. The decision runs in this order:
- The user already has access. Nothing is returned. This is the most common reason a button "disappears": you are testing while logged in as an enrolled user or an administrator who already has access.
- Open courses. The default output is empty, because an open course needs no enrolment. A filter lets you add one if you want a call to action anyway.
- The product cannot be purchased. When the course has ended, is pre-ordered by this user, or has no seats left, a disabled button is shown with a label such as "Course ended", "Course pre-ordered" or "Course is full", built from your custom course label. Our guide to start and end dates and seat limits explains those states.
- Closed courses. A button linking to the Button URL set on the course, if one is set, otherwise nothing.
- Free courses. A small form that posts back to the course and enrols the user, with the Take this Course label. Logged-out visitors see a login prompt first.
- Buy now and Recurring courses. A paid button. If a Registration page is set in the Registration Pages settings and the shortcode is not on that page, the button is a link to the registration page with the course ID in the query string. On the registration page, or when no registration page is set, the gateway buttons themselves are rendered.
Two further details matter for paid courses. If the price is empty, nothing is rendered even though the type is paid, so a course switched to Buy now without a price shows no button. And when more than one gateway is active without a registration page, the buttons are wrapped in a dropdown whose trigger carries the price, with each gateway's button inside.
Where to place it
Typical placements that work well:
- A sales landing page built in your theme or a page builder, with the shortcode under each pricing column pointing at a different course.
- A sticky sidebar or footer bar on course pages, where the shortcode without attributes picks up the current course automatically.
- A group sales page where a team lead buys seats for a group, using
group_id. - Inside a Course Grid or course list template override, so each card carries a live button instead of a generic link.
Because the button hides for users who already have access, it is safe to leave on pages that enrolled learners also visit. Pair it with the [student] and [visitor] shortcodes when you want a "Continue course" link to appear in its place; our guide to the student and visitor shortcodes shows that pattern.
Changing the label
The default label comes from the Custom Labels settings: Take this Course and Enroll in Group are both editable under LearnDash LMS, Settings, Custom Labels, and the edit applies everywhere the button appears. For a label that depends on the course, use the learndash_payment_button_label filter, which receives the label and runs for every button:
<?php
add_filter(
'learndash_payment_button_label',
function ( $label ) {
$course_id = learndash_get_course_id();
if ( 789 === (int) $course_id && 'Take this Course' === $label ) {
return 'Start the bootcamp';
}
return $label;
}
);
On the modern registration page the checkout button is relabelled Checkout by the plugin itself through the same filter, so test your override there as well as on the course page.
Changing the markup
Each branch of the decision above has its own filter, and all of them receive the default payment parameters array with the price type and price:
learndash_payment_button_openfor open courses, default empty.learndash_payment_button_freefor the free enrolment form.learndash_payment_button_disabledfor ended, pre-ordered and full products.learndash_payment_buttonsfor the array of gateway buttons on paid products, which gateways populate and you can reorder or remove entries from.learndash_payment_buttonfor the paid output when no gateway produced a button.learndash_payment_button_dropdown_triggerandlearndash_payment_button_dropdownfor the multi-gateway dropdown.learndash_payment_button_classesfor the class list, andlearndash_payment_button_markupfor the final HTML of any button.
A simple use is adding a tracking class to every button:
<?php
add_filter(
'learndash_payment_button_classes',
function ( $classes ) {
return $classes . ' track-enrol-click';
}
);
The action learndash_payment_button_added fires after each button is generated and receives the HTML, which is useful for logging where buttons appear during a template audit.
Troubleshooting an empty button
Work through these in order when the shortcode prints nothing:
- Log out or use a private window. Enrolled users and administrators with access see no button.
- Check the price type and price. Buy now and Recurring need a non-empty price; Open never shows a button.
- On a plain page, confirm
course_idorgroup_idis set and points at a published course or group. - For paid courses, confirm at least one gateway is enabled under LearnDash LMS, Settings, Payments, and that its credentials validate. The Stripe Connect guide and the PayPal IPN guide cover gateway setup.
- If a plugin sells the course through WooCommerce, the course is usually set to Closed and the button is the WooCommerce add to cart link set in Button URL, not a LearnDash gateway button.
When to get help
Placing buttons is a few minutes' work. Building a pricing page that mixes one-off, subscription and group purchases with coupons, or a checkout that needs its own gateway, is a project our LearnDash services team handles regularly, and a LearnDash developer can also audit why a conversion page shows the wrong button state for some visitors.
Frequently asked questions
Why does the payment buttons shortcode show nothing for me?
Most often because your account already has access to the course. Test logged out. Otherwise check that the price type is not Open, that paid courses have a price, and that an ID is set when the shortcode is outside the course.
Can I show a buy button for a group?
Yes. Use group_id. Groups have the same price types as courses, and the label defaults to Enroll in Group.
Why does the button link to the registration page instead of showing PayPal or Stripe?
When a Registration page is set in LearnDash settings, paid buttons outside that page link to it, and the gateway buttons render there. Clear the registration page setting to render gateways inline.
Can I change "Take this Course" on one course only?
Yes, with the learndash_payment_button_label filter and a check on the course ID. Custom Labels changes the text site wide.
Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.
