This tutorial provides all the code which creates exactly what you see in the following screenshot:
The template enables you to create a list of unlimited questions and answers which are displayed when the user clicks the title of the question or the icon next to the title.
The icon can be changed easily and you create all your questions and answers in your WordPress editor.
The frequently asked questions template has been included in the Sample theme for ease of use or you can install it in any Genesis child theme.
All you need to do is copy and paste 4 snippets of code and you’re set.
There’s 4 types of code used to make this template:
- HTML
- CSS
- jQuery
- PHP
Any way to get this to work in a widget? I tried pasting the HTML into a text widget, but it wouldn’t work.
Its not coded to work in a widget however it may work if you remove this line of PHP code
That line restricts the jQuery to only load on the page template. Not sure where your widget is coded. You could change the conditional to match the page where your widget is called.
I tried removing that line of code, but then it doesn’t really work on any page. The FAQs are automatically expanded and I lose the formatting and dash icons.
I’m trying to put a list in a widget that appears in “After Entry” on single pages.
Try this solution which i just tested. https://wpsites.net/wordpress-themes/jquery-accordian/
The one you linked to works pretty well. I have one issue with it, but I’ll post it over on that page. Thanks Brad!