Published on Oct 17, 2018

FAQs grouped by categories in Oxygen

Sridhar Katakam

This members-only tutorial provides the steps to display Frequently Asked Questions grouped by categories in Oxygen.

We are going to

  • register a `faq` Custom Post Type (CPT)
  • register a `faq_category` custom taxonomy attached to the faq CPT
  • enter the question as title and answer as the content for the FAQ entries
  • load jQuery Collapse for the expand-collapse using My Custom Functionality plugin
  • edit FAQs Page with Oxygen editor and use a Code Block with the required PHP, JavaScript and CSS.
https://www.youtube.com/watch?v=cEsznBqMC8Q

In the PHP code, we shall retrieve the terms of the faq_category taxonomy, loop through them and write a custom WP Query to pull all faq entries that belong to that taxonomy and output them in a format suitable for jQuery Collapse.

Step 1

Install and activate Custom Post Type UI plugin.

Go to CPT UI > Add/Edit Post Types and add the FAQ post type.

Go to Add/Edit Taxonomies and add the FAQ Category taxonomy.

Attach it to FAQs.

In the Settings section, set Hierarchical to True so it behaves like categories and not tags.

Step 2

Go to FAQs > Add New and add your FAQ entries. Select the appropriate FAQ category and publish.

Step 3

Install and activate My Custom Functionality plugin.

Connect to your hosting account using a FTP client and navigate to site's wp-content/plugins/my-custom-functionality-master.

Upload jquery.collapse.js to the plugin's assets/js directory.

Edit plugin.php and replace the content of custom_enqueue_files() function with

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $499 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-ocalendar-check-omagnifiercrossmenuchevron-downarrow-right