5 days ago
<?php
add_filter( 'facetwp_render_output', function( $output ) {
$facets = FWP()->helper->get_facets();
foreach ( $facets as $facet ) {
if ( 'fselect' == $facet['type'] ) {
$output['settings'][ $facet['name'] ]['showSearch'] = false;
}
}
return $output;
});
11 months ago
<?php
add_filter( 'facetwp_render_output', function( $output, $params ) {
$output['settings']['post_ids'] = FWP()->filtered_post_ids;
return $output;
}, 10, 2 );
// To access the post IDs, type "FWP.settings.post_ids" into the browser console
12 months ago
<?php
// Add to your (child) theme's functions.php
// replace "YOUR_FACET_NAME" with your *actual* facet name
add_filter( 'facetwp_render_output', function( $output ) {
$output['settings']['YOUR_FACET_NAME']['range']['min']['minDate'] = date( 'Y-m-d' );
return $output;
});
2 months ago
<?php
/**
** use label instead of showing selected values in fselect
** replace "role" with the actual facet name, and "Please select Role" with the text you want to use
**/
add_filter( 'facetwp_render_output', function( $output ) {
if ( isset( $output['settings']['role'] ) ) {
$output['settings']['role']['overflowText'] = 'Please select Role';
$output['settings']['role']['numDisplayed'] = 0;
}
return $output;
});
4 months ago
<?php
/** translate text strings for use with the date range facet **/
add_filter( 'facetwp_render_output', function( $output, $params ) {
if ( isset( $output['settings']['my_date_range'] ) ) {
$output['settings']['my_date_range']['locale'] = [
'weekdays_short' => ['Dg', 'Dl', 'Dt', 'Dc', 'Dj', 'Dv', 'Ds'], // abbreviations for Sun to Sat
'months_short' => ['Gen', 'Febr', 'Març', 'Abr', 'Maig', 'Juny', 'Jul', 'Ag', 'Set', 'Oct', 'Nov', 'Des'], // abreviations for months Jan to Dec
'months' => ['Gener', 'Febrer', 'Març', 'Abril', 'Maig', 'Juny', 'Juliol', 'Agost', 'Setembre', 'Octubre', 'Novembre', 'Desembre'], //full names for months Jan to Dec
'firstDayOfWeek' => 1, // 1 is Monday, 0 is Sunday
'clearText' => 'Clear' // text for clear button
];
}
return $output;
}, 10, 2 );
1 year ago
<?php
// Add to your (child) theme's functions.php
// replace "YOUR_FACET_NAME" with your *actual* facet name
add_filter( 'facetwp_render_output', function( $output ) {
$output['settings']['YOUR_FACET_NAME']['minDate'] = '2021-03-21';
$output['settings']['YOUR_FACET_NAME']['maxDate'] = '2021-12-31';
return $output;
});
2 years ago
<?php
// Add to your (child) theme's functions.php
// @link https://docs.wp-rocket.me/article/90-getrocketcdnurl
add_filter( 'facetwp_render_output', function( $output, $params ) {
if ( function_exists( 'get_rocket_cdn_url' ) ) {
$html = $output['template'];
$html = str_replace( get_home_url(), get_rocket_cdn_url( get_home_url() ), $html );
$output['template'] = $html;
}
return $output;
}, 10, 2 );
2 years ago
<?php
/** return custom data in the json facet returns on refresh
** access with FWP.settings.my_data in JS
*/
add_filter( 'facetwp_render_output', function( $output, $params ) {
$output['settings']['my_data'] = 'some data';
return $output;
}, 10, 2 );
3 years ago
<?php
/** custom number format for a slider facet
** change_me needs to be changed to the name of the slider facet
**/
add_filter( 'facetwp_render_output', function( $output, $params ) {
if ( isset( $output['settings']['change_me'] ) ) {
$output['settings']['change_me']['format'] = '0,0.0000';
}
return $output;
}, 10, 2 );
4 years ago
add_filter( 'facetwp_render_output', function( $output ) {
$output['settings']['location']['numDisplayed'] = 1;
return $output;
});