This file contains 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 the name of your facet | |
$params['facet_value'] = get_the_date( 'Ymd', $params['post_id'] ); | |
} | |
return $params; | |
}, 10, 2 ); |
This file contains 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 | |
/* limit types searched on wp search page */ | |
add_action( 'pre_get_posts', function( $query ) { | |
if ( !is_admin() && $query->is_main_query() && $query->is_search() ) { | |
$query->set('post_type', 'post'); | |
} | |
} ); |
This file contains 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 | |
function starkatcher_index_latlng( $params, $class ) { | |
if ( 'location' == $params['facet_name'] ) { | |
$latlong = explode(',', get_post_meta( $params['post_id'], 'sk-location', true )); | |
$lat = $latlong[0]; | |
$long = $latlong[1]; | |
// foreach ( (array) $params['facet_value'] as $post ) { | |
$params['facet_value'] = $lat; |
This file contains 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( 'plugins_loaded', 'facetmap_load_textdomain' ); | |
/** | |
* Load plugin textdomain. | |
*/ | |
function facetmap_load_textdomain() { | |
load_plugin_textdomain( 'fwp-map' ); | |
} |
This file contains 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
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if ('undefined' !== typeof FWP.facets['facet_name'] ) { | |
if ( $.inArray( 'some_value', FWP.facets['facet_name'] ) > -1 ) { | |
// update form value as needed in gravity form | |
} | |
} | |
}); | |
})(jQuery); |
This file contains 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_head', function() { | |
?> | |
<script> | |
(function($) { | |
$(function() { | |
FWP.hooks.addAction('facetwp/loaded', function() { | |
/* run code here after facetwp loaded, 100 below can be modified to set priority order */ | |
}, 100 ); |
This file contains 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 | |
/** | |
** look up and index a value from a post relationship field | |
** set the datasource to the relationship field | |
** get the post id of that related post and use it to | |
** lookup its associated value | |
** for ACF you may want get_field() instead of get_post_meta() | |
** remember to do a full re-index after adding code | |
** check the wp_facetwp_index table if needed to see what values are being indexed | |
**/ |
This file contains 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 while ( have_posts() ): the_post(); ?> | |
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> | |
<?php endwhile; ?> |
This file contains 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_use_search_relevancy', function( $value, $class ) { | |
if ( 'foo/bar' == $class->http_params['uri'] ) { | |
return false; | |
} | |
return $value; | |
}, 10, 2 ); |
This file contains 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 | |
// check for job_listings archive and don't use the query unless it is using menu_order | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( isset( $query->query_vars['post_type'] ) && 'job_listing' == $query->query_vars['post_type'] | |
&& ( ! isset( $query->query_vars['taxonomy'] ) || '' == $query->query_vars['taxonomy'] ) ) { | |
if ( isset( $query->query_vars['order_by']['menu_order'] ) ) { | |
return true; | |
} else { | |
return false; | |
} |