FAQ Manager Shortcodes

Below, you’ll find a detailed guide on how to add the FAQ Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the FAQ Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the FAQ Manager Plugin and the shortcodes it provides:

Plugin Icon
FAQ Manager

"FAQ Manager is a WordPress plugin designed to efficiently manage and display FAQs on your website. It simplifies creating, organizing, and publishing FAQs, enhancing user experience."

★★★★✩ (12) Active Installs: 3000+ Tested with: 6.1.4 PHP Version: 7.0
Included Shortcodes:
  • [faq]
  • [faqlist]
  • [faqtaxlist]
  • [faqcombo]

FAQ Manager [faq] Shortcode

The WordPress-FAQ-Manager shortcode is a vital tool used to display FAQ content on your site. It fetches FAQs based on ID, topic or tag, and limits the displayed items. The shortcode defines the display speed, expandable content, content filter, and more link. It also includes pagination and calls for CSS and JS files for styling and functionality.

Shortcode: [faq]

Parameters

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

  • faq_topic – Defines specific topic(s) for the FAQs to be displayed.
  • faq_tag – Specifies the tag(s) of the FAQs to be displayed.
  • faq_id – Displays the FAQ with the specific ID provided.
  • limit – Sets the maximum number of FAQs to be displayed.

Examples and Usage

Basic example – Displaying FAQs by referencing their ID.

[faq faq_id=1 /]

Advanced examples

Displaying FAQs by referencing their topic. This will show all FAQs that are tagged with the specified topic.

[faq faq_topic="wordpress" /]

Displaying FAQs by referencing their tag. This will show all FAQs that are tagged with the specified tag.

[faq faq_tag="plugin" /]

Displaying a limited number of FAQs. This will show the specified number of FAQs.

[faq limit=5 /]

Combining multiple parameters. This will show a limited number of FAQs that are tagged with the specified topic and tag.

[faq faq_topic="wordpress" faq_tag="plugin" limit=5 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'faq',                           array( $this, 'shortcode_main'          )           );

Shortcode PHP function:

                    function shortcode_main( $atts, $content = null ) {

		// Parse my attributes.
		$atts   = shortcode_atts( array(
			'faq_topic' => '',
			'faq_tag'   => '',
			'faq_id'    => 0,
			'limit'     => 10,
		), $atts, 'faq' );

		// Set each possible taxonomy into an array.
		$topics = ! empty( $atts['faq_topic'] ) ? explode( ',', esc_attr( $atts['faq_topic'] ) ) : array();
		$tags   = ! empty( $atts['faq_tag'] ) ? explode( ', ', esc_attr( $atts['faq_tag'] ) ) : array();

		// Determine my pagination set.
		$paged  = ! empty( $_GET['faq_page'] ) ? absint( $_GET['faq_page'] ) : 1;

		// Fetch my items.
		if ( false === $faqs = WPFAQ_Manager_Data::get_main_shortcode_faqs( $atts['faq_id'], $atts['limit'], $topics, $tags, $paged ) ) {
			return;
		}

		// Set some variables used within.
		$speed  = apply_filters( 'wpfaq_display_expand_speed', 200, 'main' );
		$expand = apply_filters( 'wpfaq_display_content_expand', true, 'main' );
		$filter = apply_filters( 'wpfaq_display_content_filter', true, 'main' );
		$exlink = apply_filters( 'wpfaq_display_content_more_link', array( 'show' => 1, 'text' => __( 'Read More', 'wordpress-faq-manager' ) ), 'main' );
		$pageit = apply_filters( 'wpfaq_display_shortcode_paginate', true, 'main' );

		// Make sure we have a valid H type to use.
		$htype  = WPFAQ_Manager_Helper::check_htype_tag( 'h3', 'main' );

		// Set some classes for markup.
		$dclass = ! empty( $expand ) ? 'faq-list expand-faq-list' : 'faq-list';
		$bclass = ! empty( $expand ) ? 'single-faq expand-faq' : 'single-faq';
		$tclass = ! empty( $expand ) ? 'faq-question expand-title' : 'faq-question';

		// Call our CSS and JS files.
		wp_enqueue_style( 'faq-front' );
		wp_enqueue_script( 'faq-front' );

		// Start my markup.
		$build  = '';

		// The wrapper around.
		$build .= '<div id="faq-block" class="faq-block-wrap" name="faq-block">';
			$build .= '<div class="' . esc_attr( $dclass ) . '" data-speed="' . absint( $speed ) . '">';

			// Loop my individual FAQs
			foreach ( $faqs as $faq ) {

				// Wrap a div around each item.
				$build .= '<div class="' . esc_attr( $bclass ) . '">';

					// Our title setup.
					$build .= '<' . esc_attr( $htype ) . ' id="' . esc_attr( $faq->post_name ) . '" name="' . esc_attr( $faq->post_name ) . '" class="' . esc_attr( $tclass ) . '">' . esc_html( $faq->post_title ) .  '</' . esc_attr( $htype ) . '>';

					// Our content display.
					$build .= '<div class="faq-answer" rel="' . esc_attr( $faq->post_name ) . '">';

					// Show the content, with the optional filter.
					$build .= false !== $filter ? apply_filters( 'the_content', $faq->post_content ) : wpautop( $faq->post_content );

					// Show the "read more" link.
					if ( ! empty( $exlink ) ) {

						// Fetch the link and text to display.
						$link   = get_permalink( absint( $faq->ID ) );
						$more   = ! empty( $exlink['text'] ) ? $exlink['text'] : __( 'Read More', 'wordpress-faq-manager' );

						// The display portion itself.
						$build .= '<p class="faq-link">';
						$build .= '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $faq->post_title ) .  '">' . esc_html( $more ) . '</a>';
						$build .= '</p>';
					}

					// Close the div around the content display.
					$build .= '</div>';

				// Close the div around each item.
				$build .= '</div>';
			}

			// Handle our optional pagination.
			if ( ! empty( $pageit ) && empty( $atts['faq_id'] ) ) {
				$build .= WPFAQ_Manager_Helper::build_pagination( $atts, get_permalink(), $paged, 'main' );
			}

			// Close the markup wrappers.
			$build .= '</div>';
		$build .= '</div>';

		// Return my markup.
		return $build;
	}
                    

Code file location:

wordpress-faq-manager/wordpress-faq-manager/lib/shortcodes.php

FAQ Manager [faqlist] Shortcode

The WordPress FAQ Manager shortcode ‘faqlist’ displays a list of FAQs on your page. It allows customization by topic, tag, or individual FAQ id. It also includes pagination and can limit the number of FAQs shown. The output is styled and formatted for easy integration into your site.

Shortcode: [faqlist]

Parameters

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

  • faq_topic – Name of the FAQ topic to display
  • faq_tag – Specific FAQ tag to display
  • faq_id – ID of the specific FAQ to display
  • limit – Limit the number of FAQs displayed

Examples and Usage

Basic example – Display a list of FAQs with a limit of 10.

[faqlist limit=10 /]

Advanced examples

Display a list of FAQs related to a specific topic. In this case, the ‘faq_topic’ attribute is used to specify the topic.

[faqlist faq_topic="wordpress" /]

Display a list of FAQs related to multiple topics. The ‘faq_topic’ attribute can accept multiple topics separated by commas.

[faqlist faq_topic="wordpress,plugins,themes" /]

Display a specific FAQ using its ID. The ‘faq_id’ attribute is used to specify the ID of the FAQ.

[faqlist faq_id=3 /]

Display a list of FAQs tagged with a specific tag. The ‘faq_tag’ attribute is used to specify the tag.

[faqlist faq_tag="installation" /]

Display a list of FAQs related to a specific topic and tagged with a specific tag. Both ‘faq_topic’ and ‘faq_tag’ attributes are used in this example.

[faqlist faq_topic="wordpress" faq_tag="installation" /]

Display a list of FAQs with a specific limit, related to a specific topic and tagged with a specific tag. All three attributes ‘limit’, ‘faq_topic’, and ‘faq_tag’ are used in this example.

[faqlist limit=5 faq_topic="wordpress" faq_tag="installation" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'faqlist',                       array( $this, 'shortcode_list'          )           );

Shortcode PHP function:

                    function shortcode_list( $atts, $content = null ) {

		// Parse my attributes.
		$atts   = shortcode_atts( array(
			'faq_topic' => '',
			'faq_tag'   => '',
			'faq_id'    => 0,
			'limit'     => 10,
		), $atts, 'faqlist' );

		// Set each possible taxonomy into an array.
		$topics = ! empty( $atts['faq_topic'] ) ? explode( ',', esc_attr( $atts['faq_topic'] ) ) : array();
		$tags   = ! empty( $atts['faq_tag'] ) ? explode( ',', esc_attr( $atts['faq_tag'] ) ) : array();

		// Determine my pagination set.
		$paged  = ! empty( $_GET['faq_page'] ) ? absint( $_GET['faq_page'] ) : 1;

		// Fetch my items.
		if ( false === $faqs = WPFAQ_Manager_Data::get_main_shortcode_faqs( $atts['faq_id'], $atts['limit'], $topics, $tags, $paged ) ) {
			return;
		}

		// Call our CSS file.
		wp_enqueue_style( 'faq-front' );
		wp_enqueue_script( 'faq-front' );

		// Set some variables used within.
		$pageit = apply_filters( 'wpfaq_display_shortcode_paginate', true, 'list' );

		// Start my markup.
		$build  = '';

		// The wrapper around.
		$build .= '<div id="faq-block" class="faq-block-wrap" name="faq-block">';
			$build .= '<div class="faq-list">';

			// Set up a list wrapper.
			$build .= '<ul>';

			// Loop my individual FAQs
			foreach ( $faqs as $faq ) {

				// Get my permalink.
				$link   = get_permalink( $faq->ID );

				// Wrap a li around each item.
				$build .= '<li class="faqlist-question">';

				// The actual link.
				$build .= '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $faq->post_title ) .  '">' . esc_html( $faq->post_title ) .  '</a>';

				// Close the li around each item.
				$build .= '</li>';
			}

			// Close up the list wrapper.
			$build .= '</ul>';

			// Handle our optional pagination.
			if ( ! empty( $pageit ) && empty( $atts['faq_id'] ) ) {
				$build .= WPFAQ_Manager_Helper::build_pagination( $atts, get_permalink(), $paged, 'list' );
			}

			// Close the markup wrappers.
			$build .= '</div>';
		$build .= '</div>';

		// Return my markup.
		return $build;
	}
                    

Code file location:

wordpress-faq-manager/wordpress-faq-manager/lib/shortcodes.php

FAQ Manager [faqtaxlist] Shortcode

The WordPress-FAQ-Manager plugin shortcode, ‘faqtaxlist’, is used to display a list of FAQ topics or tags. It takes attributes such as ‘type’, ‘desc’, and ‘linked’. The ‘type’ attribute specifies whether to display ‘topics’ or ‘tags’. The ‘desc’ attribute controls the description display, while ‘linked’ determines if the terms are hyperlinked.

Shortcode: [faqtaxlist]

Parameters

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

  • type – Determines the type of taxonomy to display, either ‘topics’ or ‘tags’.
  • desc – If set, the description of the taxonomy term will be displayed.
  • linked – Determines if the taxonomy term should be linked to its archive page.

Examples and Usage

Basic example – Display a list of FAQ topics without descriptions

[faqtaxlist type='topics' desc='' linked=true]

Advanced examples

Display a list of FAQ topics with descriptions

[faqtaxlist type='topics' desc='true' linked=true]

Display a list of FAQ tags without links

[faqtaxlist type='tags' linked=false]

Display a list of FAQ tags with descriptions and without links

[faqtaxlist type='tags' desc='true' linked=false]
These examples showcase the flexibility of the ‘faqtaxlist’ shortcode. By adjusting the parameters, you can control whether the list displays topics or tags, whether each item is linked, and whether descriptions are included. The shortcode is designed to be easy to use, while still offering a range of options to suit your needs.

PHP Function Code

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

Shortcode line:

add_shortcode( 'faqtaxlist',                    array( $this, 'shortcode_tax_list'      )           );

Shortcode PHP function:

                    function shortcode_tax_list( $atts, $content = null ) {

		// Parse my attributes.
		$atts   = shortcode_atts( array(
			'type'      => 'topics',
			'desc'      => '',
			'linked'    => true,
		), $atts, 'faqtaxlist' );

		// If no type is set, or it's not a valid one, bail.
		if ( empty( $atts['type'] ) || ! in_array( esc_attr( $atts['type'] ), array( 'topics', 'tags' ) ) ) {
			return;
		}

		// Now set the actual type we have registered, along with the description flag.
		$type   = ! empty( $atts['type'] ) && 'topics' === esc_attr( $atts['type'] ) ? 'faq-topic' : 'faq-tag';

		// Fetch my terms.
		if ( false === $terms = WPFAQ_Manager_Data::get_tax_shortcode_terms( $type ) ) {
			return;
		}

		// Call our CSS file.
		wp_enqueue_style( 'faq-front' );
		wp_enqueue_script( 'faq-front' );

		// Make sure we have a valid H type to use.
		$htype  = WPFAQ_Manager_Helper::check_htype_tag( 'h3', 'taxlist' );

		// Start my markup.
		$build  = '';

		// The wrapper around.
		$build .= '<div id="faq-block" name="faq-block" class="faq-block-wrap faq-taxonomy faq-taxonomy-' . sanitize_html_class( $type ) . '">';

		// Loop my individual terms
		foreach ( $terms as $term ) {

			// Wrap a div around each item.
			$build .= '<div id="' . esc_attr( $term->slug ) . '" class="faq-item faq-taxlist-item">';

				// Our title setup.
				$build .= '<' . esc_attr( $htype ) . ' name="' . esc_attr( $term->slug ) . '">';

				// The title name (linked or otherwise).
				$build .= ! empty( $atts['linked'] ) ? '<a href="' . get_term_link( $term, $type ) . '">' . esc_html( $term->name ) . '</a>' : esc_html( $term->name );

				// Close the title.
				$build .= '</' . esc_attr( $htype ) . '>';

				// Optional description.
				if ( ! empty( $atts['desc'] ) && ! empty( $term->description ) ) {
					$build .= wpautop( esc_attr( $term->description ) );
				}

			// Close the div around each item.
			$build .= '</div>';
		}

		// Close the wrapper
		$build .= '</div>';

		// Return my markup.
		return $build;
	}
                    

Code file location:

wordpress-faq-manager/wordpress-faq-manager/lib/shortcodes.php

FAQ Manager [faqcombo] Shortcode

The WordPress FAQ Manager shortcode ‘faqcombo’ is designed to display FAQs in a combined format. It fetches FAQs based on specified attributes like ‘faq_topic’, ‘faq_tag’, and ‘faq_id’. It then structures the FAQs into a scrollable list and content layout. Each FAQ is clickable, leading to its content. Additionally, it includes a ‘Back To Top’ feature for easy navigation.

Shortcode: [faqcombo]

Parameters

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

  • faq_topic – Specifies the topics to display FAQs from.
  • faq_tag – Determines the tags to filter FAQs by.
  • faq_id – Allows selection of specific FAQ by its ID.

Examples and Usage

Basic example – Display FAQs related to a specific topic using the faq_topic attribute

[faqcombo faq_topic="wordpress" /]

Advanced examples

Display FAQs related to multiple topics by providing a comma-separated list of topics in the faq_topic attribute

[faqcombo faq_topic="wordpress,plugins,themes" /]

Display a specific FAQ by its ID using the faq_id attribute

[faqcombo faq_id=3 /]

Display FAQs that have specific tags using the faq_tag attribute

[faqcombo faq_tag="tag1,tag2" /]

Combining multiple attributes to display FAQs that match specific topics, tags, and ID

[faqcombo faq_topic="wordpress" faq_tag="tag1,tag2" faq_id=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'faqcombo',                      array( $this, 'shortcode_combo'         )           );

Shortcode PHP function:

                    function shortcode_combo( $atts, $content = null ) {

		// Parse my attributes.
		$atts   = shortcode_atts( array(
			'faq_topic' => '',
			'faq_tag'   => '',
			'faq_id'    => 0,
		), $atts, 'faqcombo' );

		// Set each possible taxonomy into an array.
		$topics = ! empty( $atts['faq_topic'] ) ? explode( ',', esc_attr( $atts['faq_topic'] ) ) : array();
		$tags   = ! empty( $atts['faq_tag'] ) ? explode( ',', esc_attr( $atts['faq_tag'] ) ) : array();

		// Fetch my items.
		if ( false === $faqs = WPFAQ_Manager_Data::get_combo_shortcode_faqs( $atts['faq_id'], $topics, $tags ) ) {
			return;
		}

		// Call our CSS file.
		wp_enqueue_style( 'faq-front' );
		wp_enqueue_script( 'faq-front' );

		// Some display variables.
		$scroll = apply_filters( 'wpfaq_scroll_combo_list', true, 'combo' );
		$filter = apply_filters( 'wpfaq_display_content_filter', true, 'combo' );
		$bktop  = apply_filters( 'wpfaq_display_content_backtotop', true, 'combo' );

		// Make sure we have a valid H type to use.
		$htype  = WPFAQ_Manager_Helper::check_htype_tag( 'h3', 'combo' );

		// Set a class based on the scrolling.
		$sclass = ! empty( $scroll ) ? 'faq-block-combo-wrap faq-block-combo-wrap-scroll' : 'faq-block-combo-wrap';

		// Start my markup.
		$build  = '';

		// The wrapper around the entire thing.
		$build .= '<div id="faq-block" class="faq-block-wrap ' . esc_attr( $sclass ) . '" name="faq-block" rel="faq-top">';

			// Wrap the list portion of the combo.
			$build .= '<div class="faq-list">';
				$build .= '<ul>';

				// Loop my individual FAQs
				foreach ( $faqs as $faq ) {

					// Wrap a li around each item.
					$build .= '<li class="faqlist-question">';

					// The actual link.
					$build .= '<a href="#' . esc_attr( $faq->post_name ) . '" rel="' . esc_attr( $faq->post_name ) . '">' . esc_html( $faq->post_title ) .  '</a>';

					// Close the li around each item.
					$build .= '</li>';
				}

				// Close the wrapper around the list portion.
				$build .= '</ul>';
			$build .= '</div>';

			// Wrap the content portion of the combo.
			$build .= '<div class="faq-content">';

				// Loop my individual FAQs
				foreach ( $faqs as $faq ) {

					// Wrap a div around each item.
					$build .= '<div class="single-faq" rel="' . esc_attr( $faq->post_name ) . '">';

						// Our title setup.
						$build .= '<' . esc_attr( $htype ) . ' id="' . esc_attr( $faq->post_name ) . '" name="' . esc_attr( $faq->post_name ) . '" class="faq-question">' . esc_html( $faq->post_title ) .  '</' . esc_attr( $htype ) . '>';

						// Handle the content itself.
						$build .= '<div class="faq-answer">';

							// Show the content, with the optional filter.
							$build .= false !== $filter ? apply_filters( 'the_content', $faq->post_content ) : wpautop( $faq->post_content );

							// Show the "back to top" if requested.
							if ( ! empty( $bktop ) ) {
								$build .= '<p class="scroll-back"><a href="#faq-block">' . __( 'Back To Top', 'wordpress-faq-manager' ) . '</a></p>';
							}

						// Close the div around each bit of content.
						$build .= '</div>';

					// Close the div around each item.
					$build .= '</div>';
				}

			// Close the wrap the content portion of the combo.
			$build .= '</div>';

		// Close the entire wrapper.
		$build .= '</div>';

		// Return my markup.
		return $build;
	}
                    

Code file location:

wordpress-faq-manager/wordpress-faq-manager/lib/shortcodes.php

Conclusion

Now that you’ve learned how to embed the FAQ Manager Plugin shortcodes, 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 *