Skip to content

Instantly share code, notes, and snippets.

@wpmark
Last active March 14, 2023 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmark/fd11b424b3e7207c824ecf190a6af16f to your computer and use it in GitHub Desktop.
Save wpmark/fd11b424b3e7207c824ecf190a6af16f to your computer and use it in GitHub Desktop.
Register Facets with the excellent FacetWP plugin via PHP
<?php
/**
* Registers the Facets with FacetWP.
*
* @param array $facets The current array of registered facets.
* @return array $facets The modified array of registered facets.
*/
function hd_utility_add_job_facets( $facets ) {
// add the job industry facet.
$facets['job_industry'] = array(
'name' => 'job_industry',
'label' => __( 'Job Industry', 'hd-utility' ),
'type' => 'checkboxes',
'source' => 'tax/hd_job_industry',
'parent_term' => '',
'modifier_type' => 'off',
'modifier_values' => '',
'hierarchical' => 'yes',
'show_expanded' => 'no',
'ghosts' => 'no',
'preserve_ghosts' => 'no',
'operator' => 'or',
'orderby' => 'count',
'count' => '-1',
'soft_limit' => '10',
);
// return the maybe modified facets.
return $facets;
}
add_filter( 'facetwp_facets', 'hd_utility_add_job_facets', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment