<?php
/**
* [facetwp template="publications" project="housing"]
*
* Look for a "project" shortcode attribute. If one exists,
* update the query to narrow results by that project
*/
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
foreach ( FWP()->display->shortcode_atts as $atts ) {
if ( isset( $atts['template'] ) && isset( $atts['project'] ) ) {
// Narrow results by the given project
$query_args['tax_query'] = [
[
'taxonomy' => 'project',
'field' => 'slug',
'terms' => $atts['project']
]
];
break;
}
}
return $query_args;
}, 10, 2 );