Shortcodes

FacetWP features (facets, templates, pagination, sorting, etc) are added to your site using shortcodes. Each shortcode is covered below.

Shortcode placement

Shortcodes can be added to the body field of your pages, or into Text widgets (Appearance > Widgets). If you’re using the WordPress 5.0 block editor, you can paste shortcodes into a Shortcode block:

If you’d prefer to use PHP template files, we provide a helper function:

<?php echo facetwp_display( 'facet', 'my_facet_name' ); ?>
<?php echo facetwp_display( 'template', 'my_template_name' ); ?>
<?php echo facetwp_display( 'pager' ); ?>

Display a facet

[facetwp facet="my_facet_name"]

Use the facet name, not the label

Display a template

[facetwp template="my_template_name"]

Use the template name, not the label

Pagination

[facetwp pager="true"]

Per-page box

[facetwp per_page="true"]

Control the dropdown choices via the facetwp_per_page_options hook

User selections list

[facetwp selections="true"]

Result counts

[facetwp counts="true"]

Control the output via the facetwp_result_count hook

Sort box

[facetwp sort="true"]

Control the dropdown choices via the facetwp_sort_options hook