Product FAQs developer reference

Filters for changing Product FAQs’ tab and question list in code.

Beka Rice Avatar

Written by

Last updated


Product FAQs has no settings screen, so changes to the tab and the FAQ list are made with filters in a small custom plugin or your theme’s functions.php. For adding FAQs to products, see Get started with Product FAQs.

Filters

wcpf_product_faqs_tab_title

Filters the product tab’s title. Default FAQs.

wcpf_product_faqs_tab_priority

Filters the tab’s position among the product tabs. Default 50, which puts it after WooCommerce’s Description (10), Additional information (20) and Reviews (30) tabs. Return a lower number to move it earlier.

wcpf_product_faqs_title

Filters the heading above the FAQs, in both the tab and the [wcpf_product_faqs] shortcode. Default FAQs.

wcpf_product_faqs_expanded_by_default

Return true to show every answer open when the page loads. Default false. Shoppers can still click a question to close its answer.

wcpf_product_faqs_disable_styling

Return true to stop the plugin’s stylesheet from loading, so you can style the FAQs with your own CSS. Default false. Without the stylesheet, answers aren’t hidden, so they start open, and clicking a question still closes and opens its answer.

wcpf_product_faqs_before

Filters text shown above the questions, below the heading. Default empty. The value is escaped as plain text, so HTML tags show as text rather than formatting.

wcpf_product_faqs_after

Filters text shown below the questions. Default empty. Escaped as plain text, like wcpf_product_faqs_before.

Recipes

Rename the tab and the heading

add_filter( 'wcpf_product_faqs_tab_title', function() {
	return __( 'Questions', 'your-text-domain' );
} );

add_filter( 'wcpf_product_faqs_title', function() {
	return __( 'Frequently asked questions', 'your-text-domain' );
} );

To change these labels without code, use a translation plugin; see changing text in a plugin.

Show the FAQs tab first

add_filter( 'wcpf_product_faqs_tab_priority', function() {
	return 5;
} );

Open every answer by default

add_filter( 'wcpf_product_faqs_expanded_by_default', '__return_true' );

Add a line below the FAQs

add_filter( 'wcpf_product_faqs_after', function() {
	return __( 'Still have a question? Contact us before you order.', 'your-text-domain' );
} );

Shortcode

[wcpf_product_faqs] outputs the FAQs of the product the page shows, with the heading from wcpf_product_faqs_title. It takes no attributes, and it outputs nothing on pages that aren’t product pages. The FAQ stylesheet loads only on single product pages.

CSS classes

For custom styling, the FAQs use this markup:

ClassElement
wcpf-product-faqsThe wrapper around all FAQs
wcpf-product-faqs-expandedAdded to the wrapper when wcpf_product_faqs_expanded_by_default returns true
wcpf-product-faqs-faqOne question and its answer
wcpf-product-faqs-faq-questionThe question, which opens and closes the answer on click
wcpf-product-faqs-faq-answerThe answer

For where to add CSS, see how to add custom CSS to your site.

Keep learning