Quick and Easy FAQs Shortcode

Below, you’ll find a detailed guide on how to add the Quick and Easy FAQs Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Quick and Easy FAQs Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Quick and Easy FAQs Plugin and the shortcodes it provides:

Plugin Icon
Quick and Easy FAQs

"Quick and Easy FAQs is a user-friendly WordPress plugin that simplifies the process of creating, organizing, and displaying frequently asked questions on your website."

★★★★☆ (34) Active Installs: 20000+ Tested with: 6.2.3 PHP Version: 5.6
Included Shortcodes:
  • [faqs]

Quick and Easy FAQs [faqs] Shortcode

The Quick-and-Easy-FAQs shortcode displays a list of frequently asked questions on your WordPress site. It allows customization of the display style, ordering, and limit of FAQs to be shown. The ‘faqs’ shortcode supports various styles such as ‘toggle’ and ‘accordion’. It also offers an option to filter FAQs and adjust their order. The ‘limit’ parameter controls the number of FAQs displayed.

Shortcode: [faqs]

Parameters

Here is a list of all possible faqs shortcode parameters and attributes:

  • style – defines the display style of FAQs (toggle, accordion, etc.)
  • filter – allows to filter FAQs by certain criteria
  • orderby – determines the ordering of FAQs (by date, etc.)
  • order – sets the direction of FAQs ordering (DESC for newest first)
  • limit – restricts the number of FAQs to be displayed

Examples and Usage

Basic Example – The shortcode is used to display a list of frequently asked questions (FAQs) in a default style, ordered by date in a descending order, and without any limit to the number of FAQs displayed.

[faqs /]

Advanced Examples

Displaying FAQs in an accordion style, ordered by title in ascending order, and limited to the first 10 FAQs.

[faqs style="accordion" orderby="title" order="ASC" limit=10 /]

Displaying FAQs in a toggle-grouped style, with a filter applied to only show FAQs from certain groups. The FAQs are ordered by date in descending order, and without any limit to the number of FAQs displayed.

[faqs style="toggle-grouped" filter="group1,group2" /]

Displaying FAQs in the default style, ordered by date in ascending order, and with an AJAX call to the admin-ajax.php file for dynamic content loading.

[faqs order="ASC" qaef_object="ajaxurl" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [faqs] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'faqs', array( $this, 'display_faqs_list' ) );

Shortcode PHP function:

function display_faqs_list( $attributes ) {

		$attributes = $this->old_shortcode_fallback( $attributes );

		extract(
			shortcode_atts(
				array(
					'style'   => '',    // Possible Values: toggle, accordion, toggle-grouped, accordion-grouped
					'filter'  => false,
					'orderby' => 'date',
					'order'   => 'DESC',
					'limit'   => -1,
				),
				$attributes,
				'faqs'
			)
		);

		// faq groups filter.
		if ( isset( $filter ) && ! empty( $filter ) && 'true' != $filter ) {
			$filter = explode( ',', $filter );
		}

		ob_start();

		$faqs_query = new FAQs_Query( $style, $filter, $orderby, $order, $limit );
		$faqs_query->render();

		wp_localize_script(
			$this->plugin_name,
			'qaef_object',
			array(
				'ajaxurl' => admin_url( 'admin-ajax.php' ),
				'style'   => $style,
			)
		);
		wp_enqueue_script( $this->plugin_name );

		return ob_get_clean();

	}

Code file location:

quick-and-easy-faqs/quick-and-easy-faqs/frontend/class-shortcode.php

Conclusion

Now that you’ve learned how to embed the Quick and Easy FAQs Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *