• Resolved adriandambrine

    (@adriandambrine)


    Hi,

    I would like to add an hypertext under every result (“go back to quiz list”). Can you tell me, please, where should I inject a code in the extension code to do that ?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    Hi Adrian,
    before doing the following, make a backup of functions.php located in your theme folder.

    Adding the following code to your theme’s functions.php file will add a function to quizzes that will automatically insert a link “Go back to quiz list” to the results text.

    In the code, you will need to update the line const page_url = "#"; to replace # with the URL of the page you want to link to.

    I also gave the link the classes of yellowBtn m-auto mt-3, which are the classes used by your theme to create those yellow buttons. Feel free to remove that if you want it to look more like a regular link.

    function hdq_adriandambrine_after_quiz()
    {
    	?>
    <script>
    function hdq_adriandambrine_after_quiz(){
    	// automatically place a link in the results text
    	const page_url = "#";
    	const pass_text = document.getElementsByClassName("hdq_result_pass")[0];
    	const fail_text = document.getElementsByClassName("hdq_result_fail")[0];
    	const html = '<a href = "' + page_url + '" class = "yellowBtn m-auto mt-3">Go back to quiz list</a>';
    	pass_text.insertAdjacentHTML("beforeend", html);
    	fail_text.insertAdjacentHTML("beforeend", html);
    }
    hdq_adriandambrine_after_quiz();
    </script>
    	<?php
    }
    add_action("hdq_after", "hdq_adriandambrine_after_quiz");
    Thread Starter adriandambrine

    (@adriandambrine)

    It worked. Thank you very much !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I insert a texte on every result box ?’ is closed to new replies.