Ultimate Faqs Shortcodes

Below, you’ll find a detailed guide on how to add the Ultimate Faqs 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 Ultimate Faqs Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Ultimate Faqs Plugin and the shortcodes it provides:

Plugin Icon
Ultimate FAQ – WordPress FAQ and Accordion Plugin

"Ultimate FAQ – WordPress FAQ and Accordion Plugin is an essential tool for efficiently managing FAQs on your site. This plugin allows you to create, organize and publicly display FAQs in an accordion layout."

★★★★☆ (393) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [ultimate-faqs]
  • [ultimate-faq-search]
  • [submit-question]
  • [select-faq]
  • [popular-faqs]
  • [recent-faqs]
  • [top-rated-faqs]

Ultimate Faqs [ultimate-faqs] Shortcode

The Ultimate FAQs shortcode is a powerful tool for displaying FAQs on your WordPress site. It allows you to customize the FAQs displayed based on various parameters like search string, tags, categories, order, and more. This shortcode works by querying the FAQ database using the parameters specified in the shortcode attributes. It then renders the FAQs that match the query. This makes it highly customizable and flexible for different FAQ display needs.

Shortcode: [ultimate-faqs]

Parameters

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

  • search_string – Text string used to search FAQs.
  • post__in – Array of FAQ post IDs to include.
  • post__in_string – Comma separated list of FAQ post IDs to include.
  • include_tag – Include FAQs with specific tags.
  • include_category_array – Array of FAQ categories to include.
  • include_category – Include FAQs in specific categories.
  • exclude_category – Exclude FAQs in specific categories.
  • include_category_ids – Include FAQs with specific category IDs.
  • exclude_category_ids – Exclude FAQs with specific category IDs.
  • include_category_children – Include child categories of the specified categories.
  • no_comments – Exclude FAQs with comments.
  • orderby – Order FAQs by specific parameters.
  • order – Sort FAQs in ascending or descending order.
  • display_all_answers – Display all answers by default.
  • group_by_category – Group FAQs by category.
  • faq_accordion – Display FAQs in an accordion view.
  • category_accordion – Display FAQ categories in an accordion view.
  • faq_page – Page number for paginated FAQs.
  • post_count – Number of FAQ posts to display.

Examples and Usage

Basic example – The ultimate-faqs shortcode is used to display a list of FAQs on a page. In its simplest form, the shortcode doesn’t require any parameters.

[ultimate-faqs]

Advanced examples

Use the ‘post_count’ parameter to limit the number of FAQs displayed. In this example, the shortcode will display only 5 FAQs.

[ultimate-faqs post_count=5]

Use the ‘include_category’ parameter to display FAQs from a specific category. In this example, the shortcode will display FAQs from the category with the ID of 3.

[ultimate-faqs include_category=3]

Combine multiple parameters to customize the FAQ display further. This example displays 10 FAQs from the category with the ID of 3, ordered by title in ascending order.

[ultimate-faqs post_count=10 include_category=3 orderby=title order=asc]

Use the ‘group_by_category’ parameter to group FAQs by their categories. This example displays all FAQs, grouped by their categories, in ascending order.

[ultimate-faqs group_by_category=true order=asc]

PHP Function Code

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

Shortcode line:

add_shortcode( 'ultimate-faqs', 'ewd_ufaq_faqs_shortcode' );

Shortcode PHP function:

function ewd_ufaq_faqs_shortcode( $atts ) {
	global $ewd_ufaq_controller;

	// Define shortcode attributes
	$faqs_atts = array(
		'search_string' 			=> '',
		'post__in' 					=> '',
		'post__in_string' 			=> '',
		'include_tag'				=> '',
		'include_category_array' 	=> array(),
		'include_category' 			=> '',
		'exclude_category' 			=> '',
		'include_category_ids' 		=> '',
		'exclude_category_ids' 		=> '',
		'include_category_children'	=> '',
		'no_comments' 				=> '',
		'orderby' 					=> '',
		'order' 					=> '',
		'display_all_answers' 		=> '',
		'group_by_category'			=> '',
		'faq_accordion'				=> '',
		'category_accordion'		=> '',
		'faq_page' 					=> 1,
		'post_count' 				=> -1
	);

	if ( empty( $faqs_atts['orderby'] ) ) { $faqs_atts['orderby'] = $ewd_ufaq_controller->settings->get_setting( 'faq-order-by' ); }

	if ( empty( $faqs_atts['order'] ) ) { $faqs_atts['order'] = $ewd_ufaq_controller->settings->get_setting( 'faq-order' ); }

	// Create filter so addons can modify the accepted attributes
	$faq_atts = apply_filters( 'ewd_ufaq_faqs_shortcode_atts', $faqs_atts );

	// Extract the shortcode attributes
	$args = shortcode_atts( $faqs_atts, $atts );

	// Convert array keys to string, filter out false or 'false' first
	if ( is_array( $args['include_category_array'] ) ) { $args['include_category'] .= implode( ',', array_keys( array_filter( filter_var_array( $args['include_category_array'], FILTER_VALIDATE_BOOLEAN, false ) ) ) ); }

	$query = new ewdufaqQuery( $args );

	$query->parse_request_args();
	$query->prepare_args();

	// Render faqs
	ewd_ufaq_load_view_files();

	$faqs = new ewdufaqViewFAQs( $args );

	$faqs->set_faqs( $query->get_faqs() );
	
	$ewd_ufaq_controller->shortcode_printing = true;

	$output = $faqs->render();

	$ewd_ufaq_controller->shortcode_printing = false;

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [ultimate-faq-search] Shortcode

The Ultimate FAQs shortcode is a versatile tool that enables users to search FAQs on your WordPress site. It allows for customization of search parameters such as category inclusion/exclusion, answer display, and comment visibility.

Shortcode: [ultimate-faq-search]

Parameters

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

  • include_category_array – Array of categories to include in the search.
  • include_category – Categories to include in the search.
  • exclude_category – Categories to exclude from the search.
  • show_on_load – If set, FAQs display immediately on page load.
  • no_comments – If set, FAQ comments will not be displayed.
  • orderby – Defines the parameter to sort FAQs by.
  • order – Determines the order of FAQs (ascending or descending).
  • display_all_answers – If set, all FAQ answers will be displayed.
  • faq_page – Specifies the page number for FAQ pagination.
  • post_count – Defines the number of FAQs to display (-1 for all).

Examples and Usage

Basic example – Display FAQs with default settings

[ultimate-faq-search]

With this basic usage of the shortcode, all FAQs will be displayed in the order set in the plugin settings. The search functionality will be enabled, and all categories will be included.

Advanced examples

Display FAQs from specific categories and limit the number of posts

[ultimate-faq-search include_category="category1,category2" post_count=5]

In this example, the shortcode will display FAQs only from the categories ‘category1’ and ‘category2’. The number of posts displayed will be limited to 5.

Display FAQs in a specific order

[ultimate-faq-search orderby="title" order="ASC"]

This shortcode will display all FAQs ordered by their title in ascending order. You can change the ‘orderby’ parameter to customize the sorting field (e.g., date, ID, author, etc.), and the ‘order’ parameter to set the sorting order (ASC for ascending, DESC for descending).

Hide comments and answers on load

[ultimate-faq-search no_comments="true" show_on_load="false"]

In this example, the shortcode will hide the comments and answers when the FAQs are initially loaded. Users will need to click on the FAQ to view the answer.

PHP Function Code

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

Shortcode line:

add_shortcode( 'ultimate-faq-search', 'ewd_ufaq_search_faqs_shortcode' );

Shortcode PHP function:

function ewd_ufaq_search_faqs_shortcode( $atts ) {
	global $ewd_ufaq_controller;

	if ( ! $ewd_ufaq_controller->permissions->check_permission( 'search' ) ) { return; }

	// Define shortcode attributes
	$faq_search_atts = array(
		'include_category_array' 	=> array(),
		'include_category' 			=> '',
		'exclude_category' 			=> '',
		'show_on_load' 				=> '',
		'no_comments'				=> '',
		'orderby' 					=> '',
		'order' 					=> '',
		'display_all_answers'		=> '',
		'faq_page'					=> 1,
        'post_count' 				=> -1,
	);

	if ( empty( $faq_search_atts['orderby'] ) ) { $faq_search_atts['orderby'] = $ewd_ufaq_controller->settings->get_setting( 'faq-order-by' ); }

	if ( empty( $faq_search_atts['order'] ) ) { $faq_search_atts['order'] = $ewd_ufaq_controller->settings->get_setting( 'faq-order' ); }

	// Create filter so addons can modify the accepted attributes
	$faq_search_atts = apply_filters( 'ewd_ufaq_faq_search_shortcode_atts', $faq_search_atts );

	// Extract the shortcode attributes
	$args = shortcode_atts( $faq_search_atts, $atts );

	// Convert array keys to string, filter out false or 'false' first
	if ( is_array( $args['include_category_array'] ) ) { $args['include_category'] .= implode( ',', array_keys( array_filter( filter_var_array( $args['include_category_array'], FILTER_VALIDATE_BOOLEAN, false ) ) ) ); }

	$query = new ewdufaqQuery( $args );

	$query->parse_request_args();
	$query->prepare_args();

	// Render faqs
	ewd_ufaq_load_view_files();

	$faqs = new ewdufaqViewFAQSearch( $args );

	$faqs->set_faqs( $query->get_faqs() );
	
	$ewd_ufaq_controller->shortcode_printing = true;

	$output = $faqs->render();

	$ewd_ufaq_controller->shortcode_printing = false;

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [submit-question] Shortcode

The Ultimate FAQs plugin shortcode, ‘submit-question’, enables users to submit FAQs on your site. It checks user permissions, accepts attributes, handles FAQ submission, and renders the FAQ view. The shortcode first checks if the user has the ‘submit-faq’ permission. If not, it returns nothing. It then defines the shortcode attributes, which can be modified by addons. Upon FAQ submission, it inserts the FAQ and displays a success message or validation errors. Finally, it renders the FAQ view.

Shortcode: [submit-question]

Parameters

Here is a list of all possible submit-question shortcode parameters and attributes:

  • success_message – A custom message displayed after a successful FAQ submission.
  • submit_faq_form_title – The title of the FAQ submission form.
  • submit_faq_instructions – Instructions for users submitting FAQs.
  • submit_text – Custom text for the FAQ submission button.

Examples and Usage

Basic example – A simple usage of the shortcode to submit a FAQ question. This example will use the default success message and instructions.

[submit-question]

Advanced examples

Submitting a FAQ question with a custom success message. After a successful submission, the user will see the ‘Thank you for your question!’ message.

[submit-question success_message='Thank you for your question!']

Submitting a FAQ question with a custom form title and instructions. The ‘Ask a Question’ title will appear above the form, and the ‘Please provide as much detail as possible.’ will guide the user on how to fill out the form.

[submit-question submit_faq_form_title='Ask a Question' submit_faq_instructions='Please provide as much detail as possible.']

Submitting a FAQ question with a custom submit button text. Instead of the default ‘Submit’ text, the button will display ‘Send Question’.

[submit-question submit_text='Send Question']

Combining multiple parameters in the shortcode. This example includes a custom success message, form title, instructions, and submit button text.

[submit-question success_message='Your question has been received!' submit_faq_form_title='Got a Question?' submit_faq_instructions='Fill out the form below.' submit_text='Ask Now']

PHP Function Code

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

Shortcode line:

add_shortcode( 'submit-question', 'ewd_ufaq_submit_faq_shortcode' );

Shortcode PHP function:

function ewd_ufaq_submit_faq_shortcode( $atts ) {
	global $ewd_ufaq_controller;

	if ( ! $ewd_ufaq_controller->permissions->check_permission( 'submit-faq' ) ) { return; }

	// Define shortcode attributes
	$submit_faq_atts = array(
		'success_message' 			=> '',
		'submit_faq_form_title' 	=> '',
		'submit_faq_instructions' 	=> '',
		'submit_text'				=> '',
	);

	// Create filter so addons can modify the accepted attributes
	$submit_faq_atts = apply_filters( 'ewd_ufaq_submit_faq_shortcode_atts', $submit_faq_atts );

	// Extract the shortcode attributes
	$args = shortcode_atts( $submit_faq_atts, $atts );

	// Handle FAQ submission
	if ( isset( $_POST['submit_question'] ) ) {

		$args['faq_submitted'] = true;

		$faq = new ewdufaqFAQ();
		$success = $faq->insert_faq();

		if ( $success ) {

			$args['update_message'] = ! empty( $args['success_message'] ) ? $args['success_message'] : $ewd_ufaq_controller->settings->get_setting( 'label-thank-you-submit' );
		}
		else {

			$args['update_message'] = '';

			foreach ( $faq->validation_errors as $validation_error ) {

				$args['update_message'] .= '<br />' . $validation_error['message'];
			}
		}
	}

	// Render faq
	ewd_ufaq_load_view_files();

	$submit_faq = new ewdufaqViewSubmitFAQ( $args );

	$ewd_ufaq_controller->shortcode_printing = true;

	$output = $submit_faq->render();

	$ewd_ufaq_controller->shortcode_printing = false;

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [select-faq] Shortcode

The Ultimate FAQs plugin shortcode, ‘select-faq’, is designed to fetch and display specific FAQs. The shortcode takes parameters like ‘faq_id’, ‘faq_name’, ‘faq_slug’, and ‘no_comments’. These parameters help in selecting the FAQs based on their ID, name, slug, or comments. The shortcode then uses these parameters to generate an array of post IDs. This array is passed to another function, ‘ewd_ufaq_faqs_shortcode’, which generates the final output.

Shortcode: [select-faq]

Parameters

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

  • faq_id – IDs of the FAQs you want to display
  • faq_name – Names of the FAQs you want to display
  • faq_slug – Slugs of the FAQs you want to display
  • no_comments – Hide comments if the value is set

Examples and Usage

Basic example – Display a specific FAQ by its ID.

[select-faq faq_id=1 /]

With this shortcode, you can target a specific FAQ by its ID and display it on your page. Replace ‘1’ with the ID of your FAQ.

Advanced examples

Display a specific FAQ by its name.

[select-faq faq_name="What is WordPress?" /]

In this example, the shortcode is used to display an FAQ based on its name. Replace ‘What is WordPress?’ with the name of your FAQ.

Display multiple FAQs by their IDs.

[select-faq faq_id="1,2,3" /]

This shortcode allows you to display multiple FAQs at once by specifying their IDs. Replace ‘1,2,3’ with the IDs of the FAQs you want to display.

Disable comments on a specific FAQ.

[select-faq faq_id=1 no_comments="yes" /]

This shortcode example shows how to disable comments on a specific FAQ. Replace ‘1’ with the ID of your FAQ.

PHP Function Code

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

Shortcode line:

add_shortcode( 'select-faq', 'ewd_ufaq_faq_shortcode' );

Shortcode PHP function:

function ewd_ufaq_faq_shortcode( $atts ) {
	global $ewd_ufaq_controller;

	// Define shortcode attributes
	$faq_atts = array(
		'faq_id' 		=> 0,
		'faq_name'		=> '',
		'faq_slug'		=> '',
		'no_comments'	=> ''
	);

	// Create filter so addons can modify the accepted attributes
	$faq_atts = apply_filters( 'ewd_ufaq_faq_shortcode', $faq_atts );

	$args = shortcode_atts( $faq_atts, $atts );

	$name_array = ! empty( $args['faq_name'] ) ? explode( ',', $args['faq_name'] ) : array();
	$slug_array = ! empty( $args['faq_slug'] ) ? explode( ',', $args['faq_slug'] ) : array();
	$id_array = ! empty( $args['faq_id'] ) ? explode( ',', $args['faq_id'] ) : array();

	$post_id_array = array();

	foreach ( $name_array as $post_name ) {

		$single_post = get_page_by_title( $post_name, 'OBJECT', EWD_UFAQ_FAQ_POST_TYPE );
		$post_id_array[] = $single_post->ID;
	}

	foreach ( $slug_array as $post_slug ) {

		$single_post = get_page_by_path( $post_slug, 'OBJECT', EWD_UFAQ_FAQ_POST_TYPE );
		$post_id_array[] = $single_post->ID;
	}

	foreach ( $id_array as $post_id ) {
		
		$post_id_array[] = (int) $post_id;
	}

	$faq_args = array(
		'post__in' 		=> $post_id_array,
		'no_comments'	=> $args['no_comments']
	);

	$output = ewd_ufaq_faqs_shortcode( $faq_args );

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [popular-faqs] Shortcode

The Ultimate FAQs shortcode ‘popular-faqs’ displays the most popular FAQs based on user interactions. It sorts FAQs in descending order by popularity. You can modify the number of FAQs displayed by changing the ‘post_count’ attribute. By default, it shows five FAQs. The ‘no_comments’ attribute can be used to exclude FAQs without comments. Shortcode: [popular-faqs post_count=”5″ no_comments=””]

Shortcode: [popular-faqs]

Parameters

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

  • no_comments – Set to ignore FAQs without any comments.
  • post_count – Determines the number of popular FAQs to display.
  • orderby – Sorts FAQs by popularity, cannot be changed.
  • order – Sets the order of FAQs to descending. Can be overridden.

Examples and Usage

Basic example – Displaying the top 5 popular FAQs without any comments.

[popular-faqs no_comments='' post_count=5 /]

Advanced examples

Displaying the top 10 popular FAQs with comments.

[popular-faqs no_comments='no' post_count=10 /]

Displaying the top 3 popular FAQs in ascending order.

[popular-faqs no_comments='' post_count=3 order='ASC' /]

Displaying the top 5 popular FAQs in descending order with comments.

[popular-faqs no_comments='no' post_count=5 order='DESC' /]

Note: In the shortcode, ‘no_comments’ parameter is for showing or hiding comments. An empty string (”) will hide comments and ‘no’ will show comments. ‘post_count’ parameter is for specifying the number of FAQs to display. ‘order’ parameter is for specifying the order of FAQs. ‘ASC’ for ascending and ‘DESC’ for descending.

PHP Function Code

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

Shortcode line:

add_shortcode( 'popular-faqs', 'ewd_ufaq_popular_faqs_shortcode' );

Shortcode PHP function:

function ewd_ufaq_popular_faqs_shortcode( $atts ) {

	$defaults = array(
		'no_comments'	=> '',
		'post_count'	=> 5
	);

	$shortcode_atts = shortcode_atts( $defaults, $atts ) ;

	$shortcode_atts['orderby'] = 'popular';
	$shortcode_atts['order'] = ! empty( $shortcode_atts['order'] ) ? $shortcode_atts['order'] : 'DESC';

	$output = ewd_ufaq_faqs_shortcode( $shortcode_atts );

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [recent-faqs] Shortcode

The Ultimate FAQs plugin shortcode is a tool that displays recent FAQs. This shortcode, add_shortcode( ‘recent-faqs’, ‘ewd_ufaq_recent_faqs_shortcode’ ), pulls the five most recent FAQs by default.

Shortcode: [recent-faqs]

Parameters

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

  • no_comments – Controls whether to display comments or not.
  • post_count – Determines the number of FAQs to display.
  • orderby – Sets the order of FAQs by their date.

Examples and Usage

Basic example – Display the five most recent FAQs on your website

[recent-faqs post_count=5 /]

Advanced examples

Display the ten most recent FAQs, excluding those without comments

[recent-faqs post_count=10 no_comments=true /]

Display the most recent FAQ, regardless of whether it has comments or not

[recent-faqs post_count=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'recent-faqs', 'ewd_ufaq_recent_faqs_shortcode' );

Shortcode PHP function:

function ewd_ufaq_recent_faqs_shortcode( $atts ) {

	$defaults = array(
		'no_comments'	=> '',
		'post_count'	=> 5
	);

	$shortcode_atts = shortcode_atts( $defaults, $atts );

	$shortcode_atts['orderby'] = 'date';

	$output = ewd_ufaq_faqs_shortcode( $shortcode_atts );

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Ultimate Faqs [top-rated-faqs] Shortcode

The Ultimate FAQs plugin shortcode ‘top-rated-faqs’ displays the top-rated FAQs on your WordPress site. It sorts FAQs based on ratings and limits the display to the top 5.

Shortcode: [top-rated-faqs]

Parameters

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

  • no_comments – controls if FAQs without comments are displayed
  • post_count – sets the number of FAQs to show, default is 5

Examples and Usage

Basic example – Displays the top 5 FAQs with the highest rating.

[top-rated-faqs]

Advanced examples

Displays the top 10 FAQs with the highest rating, excluding those without comments.

[top-rated-faqs no_comments="true" post_count=10]

Displays the top 3 FAQs with the highest rating, including those without comments.

[top-rated-faqs no_comments="false" post_count=3]

Displays all FAQs with the highest rating, excluding those without comments.

[top-rated-faqs no_comments="true" post_count=-1]

PHP Function Code

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

Shortcode line:

add_shortcode( 'top-rated-faqs', 'ewd_ufaq_top_rated_faqs_shortcode' );

Shortcode PHP function:

function ewd_ufaq_top_rated_faqs_shortcode( $atts ) {

	$defaults = array(
		'no_comments'	=> '',
		'post_count'	=> 5
	);

	$shortcode_atts = shortcode_atts( $defaults, $atts );

	$shortcode_atts['orderby'] = 'rating';

	$output = ewd_ufaq_faqs_shortcode( $shortcode_atts );

	return $output;
}

Code file location:

ultimate-faqs/ultimate-faqs/includes/template-functions.php

Conclusion

Now that you’ve learned how to embed the Ultimate Faqs 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 *