Display Messages for Correct as well as Incorrect Answers For LearnDash Quizzes

    Shreya Reddy
Listen to this article

When students attempt a quiz in LearnDash, they have an option to review their answers. It’s a great option, since students get to review their answers against the actual answers for the questions.

Along with each answer, students receive a brief explanation supporting their right or wrong answer.

I’ll explain this with an example.

So, say you have a ‘Math Quiz’, with two simple questions. At the this quiz, you’ll notice a button ‘View Questions’.


Upon clicking the button, you should see how you’ve fared for each question, and text explaining the reason for marking the question right or wrong.

By default, supporting text is shown based on the answer provided. So, if the answer you’ve provided is right, only the text for the ‘correct’ answer is shown. If the answer is wrong, the ‘incorrect’ answer text is shown.


Now, there could be a scenario, where in you’d want to display both the correct as well as incorrect answer, irrespective of what the student has chosen.

We’ll take a look at how this can be done. 🙂

[su_note note_color=”#EDEDED”]

Further Reading on ‘LearnDash Quiz Customization


LearnDash Settings for Quiz Question-Answers

For every question you add to a LearnDash quiz, there are two fields provided- ‘Message with the correct answer’, and ‘Message with the incorrect answer’.

You can enter the ‘Correct’ and ‘Incorrect’ answer text here.


Either one of these is shown, based on the student’s answer.

#1 Displaying Correct and Incorrect Answer Text for newly added LearnDash Quiz Questions

To display both messages for a quiz you are in the midst of setting up, you can take a simple route.

If you notice there is another option: ‘Same text for correct- and incorrect-message?’. You can use this option, and add both, the ‘correct’ as well as ‘incorrect’ message, so that both the messages are displayed.


This approach is simple and straightforward and you don’t need to add code. But as I mentioned, it’ll work only for questions and quizzes you’re going to create.

What if you have previously added questions and want the ‘correct’ and ‘incorrect’ message to be displayed for those answers.

We’ll take a look at how that can be done, next! 🙂


#2 Displaying Correct and Incorrect Answer Text for previously added LearnDash Quiz Questions

You’ll need to add a bit of code here. It’s pretty simple so don’t stress. Now, first things first. This is some JS code. This code can be added to your theme’s JS (in case your theme provides such an option), or can be enqueued using a custom plugin or through functions.php of your theme.

If you do not understand any of this, just follow the below steps.

#1 Create a JS file

Create a JS file, wdm_ld_quiz_answers.js and add the below code in it:

    jQuery("input[name='reShowQuestion']").on("click", function(event){
      jQuery(".wpProQuiz_response").each( function( index ){
        $question_div = jQuery( this ).prev(".wpProQuiz_question");
        question_type = $question_div.children(".wpProQuiz_questionList").attr("data-type");
        if ( question_type "single" || question_type "multiple"){
           jQuery( this ).children(".wpProQuiz_incorrect").show();
           jQuery( this ).children(".wpProQuiz_correct").show();

[su_note note_color=”#fffcde”]Developer note: LearnDash, does not selectively choose the text which has to be displayed. It adds both the text in the output, but just hides the text which does not have to be shown. The above code merely displays the hidden text. Sneaky, right :-p[/su_note]

This JS will display both the correct as well as incorrect answers for LearnDash quiz questions.

But hold on!

We’re not done. Just one more step. A bit more code.

#2 Enqueue the JS file

To make sure this JS is picked by your theme, you need to enqueue it. So, add the above wdm_ld_quiz_answers.js file, in the JS folder of your current theme. And add the below code in functions.php of your theme.

function wdm_learndash_scripts() {
    wp_enqueue_script( 'wdm-ld-answers', get_stylesheet_directory_uri() . '/js/wdm_ld_quiz_answers.js', array(), '1.0.0', true );
add_action( 'wp_enqueue_scripts', 'wdm_learndash_scripts' );

And you’re set!

Now, when student’s view their LearnDash quiz answers, they should be able to see both, correct and incorrect answer messages. 🙂


Moving On

So, this was one of our quick fix tips for your LearnDash quizzes. But that’s not all.

We’ve got more in store for you!

[su_note note_color=”#EDEDED”]

DIY Customization Tricks for your LearnDash Quizzes


Happy teaching!



Shreya Reddy

Shreya Reddy

One Response

  1. Is there a way to hide or disable this feature on questions that don’t have any message text? I have empty boxes showing up after questions with no messages entered. I don’t need messages after every question, only certain ones.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads

    Craft the perfect eLearning experience on your LearnDash LMS

    Want to make your LearnDash LMS stand out from the rest? Customize the eLearning experience for your learners without spending $1. Use our easy-to-follow 44 LearnDash Tips and Tricks to get maximum ROI. Download your free guide now