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 | |
| /** simple example of replacing values with new values in index | |
| ** rememember to reindex after adding code | |
| **/ | |
| add_filter( 'facetwp_index_row', function( $params ) { | |
| if ( 'post_type' == $params['facet_name'] ) { // 'post_type' should be replaced with your facet name | |
| $current_values = array( 'Posts', 'Products' ); // array of values currently being used that you want to replace | |
| $replace_values = array( 'Articles', 'For Sale' ); // array of values to replace with, values are in same order as above |
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 | |
| /** simple example of find and replace values in the output of a facet's html | |
| ** Be careful that this doesn't replace unwanted values, you may need to be more | |
| ** specific, such as including part of the surround html - '>Posts' to '>Articles' makes | |
| ** sure you target the word right after the processing <div> tag. | |
| **/ | |
| add_filter( 'facetwp_facet_html', function( $output, $params ) { | |
| if ( 'post_type' == $params['facet']['name'] ) { | |
| $current_values = array( 'Posts', 'Products' ); |
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 js to footer to modify date_range options **/ | |
| add_action( 'wp_footer', function() { ?> | |
| <script> | |
| (function($) { | |
| if ( 'undefined' !== typeof FWP ) { | |
| FWP.hooks.addFilter('facetwp/set_options/date_range', function(flatpickr_opts, extras) { | |
| flatpickr_opts['allowInput'] = true; | |
| return flatpickr_opts; |
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 | |
| /** replace the "Date" or "Start Date" or "End Date" text in the datepicker | |
| ** Other langauges may have different text to replace as well | |
| **/ | |
| add_filter( 'facetwp_facet_html', function( $output, $params ) { | |
| if ( 'my_date_facet' == $params['facet']['name'] ) { // change 'my_date_facet' to the name of your date picker facet | |
| $output = str_replace( 'placeholder="Date"', 'placeholder="mm/dd/yyyy"', $output ); | |
| } | |
| return $output; |
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 | |
| /** example of changing a text string using wp's gettext filter **/ | |
| add_filter( 'gettext', function ( $translated_text, $untranslated_text, $domain ) { | |
| if ( $translated_text == 'Enter location' && 'fwp' == $domain ) { | |
| $translated_text = 'Other text'; | |
| } | |
| return $translated_text; | |
| }, 10, 3 ); |
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 | |
| /** | |
| ** re-run masonry layout for beaver builder masonry post module after refreshing facets | |
| **/ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| var $element = 'undefined' == typeof element ? $( 'body' ) : $( element ), |
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 | |
| /** removes () from count, could also be used to replace with alternate bracketing or other output **/ | |
| add_filter( 'facetwp_facet_html', function( $output, $params ) { | |
| if ( 'product_categories' == $params['facet']['name'] ) { | |
| $output = preg_replace( '/\(([0-9]+)\)/', '$1', $output ); | |
| } | |
| return $output; | |
| }, 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_action( 'wp_footer', function() { | |
| ?> | |
| <script> | |
| (function($) { | |
| if ('object' !== typeof FWP) { | |
| return; | |
| } | |
| $(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
| /** fix slider in Listify */ | |
| .facetwp-type-slider .noUi-horizontal .noUi-handle.noUi-handle-upper { | |
| left: auto !important; | |
| } |
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 | |
| /** | |
| ** reload isotope for uncode theme after facet refresh | |
| **/ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { |