Gists

4 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
5 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

// replace "role" with the actual facet name!

add_filter( 'facetwp_render_output', function( $output ) {
    $output['settings']['role']['overflowText'] = 'Role';
    $output['settings']['role']['numDisplayed'] = 0;
    return $output;
});
7 months ago
<?php
/** filter locale 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 name of months Jan to Dec
            'firstDayOfWeek' => 1, // 1 is Monday, 0 is Sunday
			'clearText' => 'Clear' // text for clear button
        ];
    }
    return $output;
}, 10, 2 );
9 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']['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 );
2 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;
});
4 years ago
<?php

add_filter( 'facetwp_render_output', function( $output ) {
    $output['settings']['YOUR_FACET_NAME']['showSearch'] = false;
    return $output;
});