Now we need to enqueue that file into our theme. So open your themes function.php and add the following:
This now loads the toggle.js script to our website. You’ll also notice we have included the ‘dashicons’ from WordPress. These icons are preinstalled with WordPress, but to use them on the front end of your site, you need to enqueue them in functions.php.
Now its time to add the HTML on the page.
You can ad as many <li> list as you need for your list. You would simply change the Question and the Answer area to match your specific needs. This should be added in the editor section of your WordPress post or page. If you add HTML in your visual editor, WordPress assumes you want to display the information as text. So make sure to click the Text tab in the editor and place the HTML in the text editor. You can jump back to the Visual Editor to make edits your questions and answers.
Now its time to update the style.css file in your theme.
Test It Out
Now you should be able to publish your page or post and you will have this sleek toggle feature for your FAQ. It has plenty of possibilities.
Let me know what you think in the comments below. If you have any questions or suggestions for other tutorials, please leave those in the comments below also.