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 | |
| /** | |
| ** facetwp's color addon uses either HTML colors names (HTML color names) or hex values | |
| ** the following can map color values that aren't saved in the correct format for indexing | |
| ** remember to do a full re-index in facetwp's settings after adding your code | |
| ** check the wp_facetwp_index table in your database if you need to verify indexing is in the | |
| ** correct format | |
| **/ | |
| add_filter( 'facetwp_index_row', function( $params, $class ) { | |
| if ( 'colors' == $params['facet_name'] ) { // change 'colors' to the name of your facet |
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_filter( 'facetwp_facet_orderby', function( $orderby, $facet ) { | |
| if ( 'my_facet' == $facet['name'] ) { // change 'my_facet' to name of your facet | |
| /** get you terms in the term_order and make a list of them in the form: | |
| ** $ordered_terms = '"term_slug_1", "term_slug_2", "term_slug_3"'; | |
| ** note that the double quotes need to be part of the variable itself | |
| ** so that that it will output a string as shown in | |
| ** https://facetwp.com/documentation/facetwp_facet_orderby/ "Sort by arbitrary values" **/ |
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_filter( 'facetwp_index_row', function ( $params, $class ) { | |
| if ( 'fecha' == $params['facet_name'] ) { | |
| $date = $params['facet_display_value']; | |
| $months_en = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ); | |
| $months_es = array( 'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre' ); | |
| $date = str_replace( $months_es, $months_en, $date ); | |
| $date = date_create_from_format('j M, Y', $date); | |
| $date_formatted = date_format($date, 'Y-m-d'); |
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 'facetwp' => true to the listing facetwp template query args **/ | |
| add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
| if ( 'listings' == FWP()->helper->get_uri() && true !== $query->get( 'facetwp' ) ) { | |
| return false; | |
| } | |
| return $is_main_query; | |
| }, 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 | |
| /** | |
| * The Template for displaying product archives, including the main shop page which is a post type archive | |
| * | |
| * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. | |
| * | |
| * HOWEVER, on occasion WooCommerce will need to update template files and you | |
| * (the theme developer) will need to copy the new files to your theme to | |
| * maintain compatibility. We try to do this as little as possible, but it does | |
| * happen. When this occurs the version of the template file will be bumped and |
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 | |
| /** filters download shortcode to wrap text for 0 results in facetwp-template class | |
| ** text may need to be adjust to match site setting | |
| **/ | |
| add_filter( 'downloads_shortcode', function( $output, $atts ) { | |
| $output = str_replace( 'No Products found', '<div class="facetwp-template">No Products found</div>', $output ); | |
| return $output; | |
| }, 20, 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 js to wp_head to modify slider **/ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(function() { | |
| FWP.hooks.addAction('facetwp/set_label/slider', function($this) { | |
| var label = $this.find('.facetwp-slider-label').html(); | |
| var regex = /(^[^\s]+)/; |
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
| div[data-value="facet-value"] .fs-option-label { | |
| background: url(http://example.com/content/uploads/2018/02/some-image.jpg) 0 0 no-repeat; | |
| background-size: contain; | |
| padding-left: 20px; | |
| } |
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 | |
| /** reinitializing jetpack's lazy load after facet loads **/ | |
| add_action( 'wp_head', function() { | |
| ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| jetpackLazyImagesModule( $ ); | |
| }); |
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_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
| if ( false !== $query->get( 'lang' ) ) { | |
| $is_main_query = false; | |
| } | |
| return $is_main_query; | |
| }, 10, 2 ); |