Sure, we can try it! (Yeah it’s my only quiz)
Sure, we can try it! (Yeah it’s my only quiz)
This thread has been imported from harmonicdesign.ca/hd-quiz/
Here is the basic code:
You will need to add that code to the very top of your theme’s functions.php
file just after the opening <?php
tag. I strongly recommend making a backup of this file just in case.
EXPLANTION
So the sent code does two things. The first function tells HD Quiz to run a JavaScript function once the quiz has loaded.
The second function contains and adds the JS function to your page. The function is simple enough – it replaces the pass / fail text with whatever you put in the quiz_pass
and quiz_fail
variables. You can place any HTML in there as well, so feel free to use <a href="#" rel="nofollow ugc">this is a link</a>
to make links, or <strong>bold</strong>
to make text bold etc. I also recommend wrapping any text inside a <p>content goes here</p>
paragraph tag for the best formatting.
The downside to this method is that you cannot use a visual editor to construct your pass/fail text. The upside is that it will actually work 🙂
Wow, amazing works great! Thanks again for your help!!
Now that I tested it again, when i refresh the page, it loads the same questions every time.
First – I just took a look and it looks like you did a great job added the code 🙂
I assume you have “Randomize Question Order” enabled and that your new issue is that the question order is staying the same on each page load?
If so, this is an issue that cannot be solved without compromise. You are using a page cache solution (litespeed cache). The problem with this is that by definition – the very thing that a caching solution does – is create a static version of the page and cache it. This means that queries to your database are not happening, which means that randomized questions (or, well, anything) is not possible since whatever order they are in just gets cached.
If you were to clear your cache, you’ll see that the order will change. But then the new order will get cached and that will become the permanent order again.
The only way to solve this is to disable page caching for that page.
I’ve never used LiteSpeed Cache before, but they almost certainly have an “excludes” setting where you can choose which pages to not cache. You can use this feature to stop the /more/ page from caching and allow randomization to occur again.
Hope this makes sense!
Ok did it, thanks a lot! What’s your opinion on caching plugins like this? Should I use it or not? I’m really a beginner on this field and would like an opinion, since you seem to have great knowledge. Thanks again!
100% use a caching plugin when possible 🙂
Just remember that they CACHE. So sometimes if you update a plugin or make a change – things might look broken because your site still has old scripts cached. So if something like that happens, just remember to clear the site cache so that it can be rebuilt with the new scripts.
If you are enjoying HD Quiz please leave a review here on the official WordPress.org page. HD Quiz is developed by me, just some dude, and is supported and available for free. It may seem dumb, but truly nothing makes me happier than knowing that people are using and loving HD Quiz and my hard work.
This thread has either been marked as complete or has been automatically closed due to inactivity.