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");
It worked. Thank you very much !