Home Guides WordPress

How to add a quiz to a WordPress website

Put the LeadForms code into the post and choose how to show the quiz: with the LeadForms button, with your own WordPress button or as a block right in the post.
Copy the LeadForms code
In the quiz editor, open “Publish” → “On website” and expand the “Site code” block. Copy the code, which looks like this: <script async src="https://script.leadforms.org/v1.js" data-key="YOUR_KEY"></script>. Your key is already filled in.
It is one code for the whole site: it loads all your quizzes and widgets. If it is already on this page, you do not need to paste it again.
“Publish” → “On website” tab in LeadForms: the “Site code” block with the code to paste
Open the post in WordPress
In the WordPress dashboard, go to “Posts” → “All Posts” and open the one where you want the quiz.
WordPress dashboard: “Posts” → “All Posts”
Create a new block
In the post editor, click the “+” icon to add a block right where you want the quiz.
WordPress editor: the “+” button for adding a block
Choose the “Custom HTML” block and paste the LeadForms code
In the block list, choose “Custom HTML” and paste the LeadForms code into it. If you don’t see it in the list, use the block search or “Browse all”. Click “Save” (“Update” in older versions of WordPress).
The code has to be on every post or page where the quiz should work.
Block picker in WordPress: the “Custom HTML” block
Choose how to show the quiz and click “Publish”
Go back to LeadForms, to the “Publish” → “On website” tab. In the “Where the quiz appears” step, choose “Window over the site” or “Side panel”, and in the “How it opens” step choose, for example, “LeadForms button: in the corner or as a banner”, “Auto-open” or “Button on the page”. You can pick several at once.
If you chose “Button on the page”, that is, the LeadForms button inside the post, copy its code, which looks like this: <div data-leadforms-button="ID"></div> (ID is your quiz number).
Click the “Publish” button at the bottom of the tab. Until you do, the changes will not reach your site.
“Publish” → “On website” tab in LeadForms: the “Where the quiz appears” and “How it opens” steps and the “Publish” button
Paste the button code and save the post
If you chose “Button on the page”, go back to the post editor and paste <div data-leadforms-button="ID"></div> where the button should be: into the same “Custom HTML” block right after the LeadForms code, or into a separate “Custom HTML” block. Save the post.
You can skip this step for the LeadForms corner button and for auto-open.
Done! The quiz is live
The LeadForms button appears on the page, and clicking it opens the quiz. To check the setup, go to LeadForms, click “Check page” in the “Site code” block and enter the post’s address.
Published WordPress post: the button opens the quiz
If you prefer your own button
Use this option when the quiz should open from a button that already exists on your page rather than from the LeadForms code.
You still need the LeadForms code: paste it as in steps 1–4 above. You will not need the LeadForms button code in this case.
Get the quiz link from “Your website’s links and buttons”
In LeadForms, on the “Publish” → “On website” tab, in the “How it opens” step, expand “Your website’s links and buttons” and copy the link. These links always work: there is nothing extra to turn on or publish. The quiz will open from any button or link on your site that points to #leadforms-ID, where ID is your quiz number.
“Publish” in LeadForms: the “Your website’s links and buttons” option and the #leadforms-ID link
Add the button
Go back to editing the post and insert a button. Give it a label and set its link to #leadforms-ID, replacing ID with your quiz number.
Publish the page
The quiz will open when someone clicks the button.
If the quiz should sit right in the post
You can show the quiz as a block inside the post, with no button and no pop-up. The LeadForms code is needed here too, as in steps 1–4 above.
Choose “Block in the page”
In LeadForms, on the “Publish” → “On website” tab, in the “Where the quiz appears” step, choose “Block in the page” and click “Publish”.
“Publish” in LeadForms: the “Block in the page” option and its code
Paste the block code into the post
In the post editor, add a “Custom HTML” block where the quiz should be and paste <div data-leadforms-block="ID"></div> into it, replacing ID with your quiz number. Save the post.
Having trouble with the setup?
If something doesn't work, and we'll sort it out with you.

Still have questions? Write to us

Name *
* Required field
Email *
* Required field
Message
Write to us!
We reply within 30 seconds