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 class="fwp-grid"> | |
| <?php while ( have_posts() ) : the_post(); ?> | |
| <div class="fwp-grid-col"> | |
| <?php if ( has_post_thumbnail() ) : ?> | |
| <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a> | |
| <?php endif; ?> | |
| <?php the_title( '<h3><a href="' . esc_url( get_the_permalink() ) . '">', '</a></h3>' ); ?> | |
| </div> | |
| <?php endwhile; ?> | |
| </div> |
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 | |
| /** | |
| * adds js code to check for any facets being selected | |
| */ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| var facets_in_use = function() { | |
| var in_use = false; |
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_indexer_row_data', function( $rows, $params ) { | |
| if ( 'cases_topics' == $params['facet']['name'] ) { | |
| $post_id = $params['defaults']['post_id']; | |
| $tags = get_tags( $post_id ); | |
| if ( !empty( $tags ) ) { | |
| foreach ( $tags as $tag ) { | |
| $new_row = $params['defaults']; | |
| $new_row['facet_source'] = 'tax/post_tag'; |
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 ( 'my_facet' == $params['facet_name'] ) { // change 'my_facet' to facet name | |
| if ( $params['facet_value'] > 10000 ) { | |
| $new_params = $params; | |
| $new_params['facet_value'] = 50000; | |
| $new_params['facet_display_value'] = 'Less than 50000'; | |
| $class->insert( $new_params ); // insert each value to the database | |
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 | |
| /** make the datasource something you know will always have a value for every post - like post title - it | |
| ** is only a placeholder and won't be indexed | |
| **/ | |
| add_filter( 'facetwp_index_row', function( $params, $class ) { | |
| if ( 'search_new' == $params['facet_name'] ) { // change my_facet to name of your facet | |
| $project_id = $params['post_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 | |
| /** filters search form to replace the s input with your search facet - change fwp_search as needed | |
| ** and replace the default action with the page url of your custom search results page - change /search-results/ as needed | |
| ** may need adjusting if the search is already modified by another plugin or theme */ | |
| add_filter( 'get_search_form', function( $form ) { | |
| $form = str_replace( 'name="s"', 'name="fwp_search"', $form ); | |
| $form = preg_replace( '/action=".*"/', 'action="/search-results/"', $form ); | |
| return $form; |
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 | |
| /** | |
| * make sure both publish and inherit (for attachments) are searched on the search page | |
| * Relevanssi has an option to index attachments but the query facet detects does not include attachments | |
| * because it does not include post_status inherit | |
| */ | |
| add_action( 'pre_get_posts', function( $query ) { | |
| if ( $query->is_search() ) { | |
| $statuses = $query->get( 'post_status' ); | |
| $query->set( 'post_status', array_merge( (array)$statuses, array( 'publish', 'inherit' ) ) ); |
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-add post-clause for woocommerce after facetwp updates the query vars | |
| */ | |
| add_action( 'pre_get_posts', function( $query ) { | |
| if ( 'product_query' == $query->get('wc_query') && true == $query->get('facetwp' ) && 'price' == $query->get('orderby') ) { | |
| if ( 'DESC' == $query->get('order') ) { | |
| add_filter( 'posts_clauses', array( wc()->query, 'order_by_price_desc_post_clauses' ) ); | |
| } else { |
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 | |
| /** adds script to header with a conditional check to not scroll to top | |
| ** when the load more button has been clicked | |
| **/ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-refresh', function() { | |
| if ( FWP.is_load_more == true ) { |
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 | |
| /** adds script to header with a conditional check to not scroll to top | |
| ** when the load more button has been clicked | |
| **/ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| if (FWP.loaded) { |