This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_filter( 'facetwp_facet_orderby', function( $orderby, $facet ) { | |
| if ( 'pa_variety' == $facet['name'] ) { | |
| $orderby = 'f.facet_display_value ASC'; | |
| } | |
| return $orderby; | |
| }, 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_filter( 'facetwp_filtered_post_ids', function( $post_ids ) { | |
| $facets = FWP()->facet->facets; | |
| if ( isset( $facets['keywords'] ) && ! empty( $facets['keywords']['selected_values'] ) ) { | |
| remove_filter( 'facetwp_filtered_post_ids', [ FWP()->helper->facet_types['proximity'], 'sort_by_distance' ] ); | |
| } | |
| return $post_ids; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_action( 'wp_head', function() { | |
| ?> | |
| <script> | |
| (function($) { | |
| $(function() { | |
| if ( 'undefined' !== typeof FWP && 'undefined' !== typeof FWP.hooks) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| // Change "audio-mp3" to your layout builder's item name (which defaults to "el-XXXXX") | |
| add_filter( 'facetwp_builder_item_value', function( $value, $item ) { | |
| if ( 'audio-mp3' == $item['settings']['name'] && ! empty( $value ) ) { | |
| ob_start(); | |
| ?> | |
| <audio controls> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add the following to your (child) theme's functions.php | |
| add_action( 'wp_head', function() { | |
| ?> | |
| <script> | |
| window.addEventListener('DOMContentLoaded', function() { | |
| if ('undefined' !== typeof FWP.hooks) { | |
| FWP.hooks.addAction('facetwp/loaded', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_filer( 'facetwp_acf_display_value', function( $value, $params ) { | |
| if ( ! empty( $params['facet_name'] ) ) { | |
| $facet = FWP()->helper->get_facet_by_name( $params['facet_name'] ); | |
| if ( ! empty( $facet['source_other'] ) && empty( $value ) ) { | |
| $value = $params['facet_value']; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_filter( 'wp_insert_post_data', function( $data ) { | |
| if ( 'upt_user' == $data['post_type'] ) { | |
| $user_id = (int) $data['post_author']; | |
| $user_data = get_userdata( $user_id ); | |
| $slug = $user_data->first_name . '-' . $user_data->last_name . '-' . $user_id; | |
| $data['post_name'] = sanitize_title( $slug ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This goes within a user save hook | |
| * | |
| * First, we run a UPT sync to copy the data into the wp_post* tables | |
| * Then we re-index in FacetWP to capture the changes | |
| */ | |
| UPT()->sync->run_sync( $user_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to your (child) theme's functions.php | |
| add_filter( 'facetwp_settings_admin', function( $settings ) { | |
| unset( $settings['general']['fields']['license_key'] ); | |
| return $settings; | |
| }); |