Skip to content

Instantly share code, notes, and snippets.

@elbotho
Last active January 18, 2022 13:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbotho/cf245b8813f18d9a6887d821c21780ea to your computer and use it in GitHub Desktop.
Save elbotho/cf245b8813f18d9a6887d821c21780ea to your computer and use it in GitHub Desktop.
FacetWP little helper to find active facets from php
<?php
//helper in functions.php
function my_get_facet_vars(){
$vars = [];
foreach ($_GET as $key => $value) {
$pos = strpos($key, 'fwp_');
if ($pos == 0) {
$key = str_replace("fwp_", "", $key);
$vars[$key] = $value;
}
}
return $vars;
}
// and use this to check for active filters
if( count($filters) == 0 ) //do stuff;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment