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 | |
/** | |
* initially hide the map facet ( .facetwp-facet-map ) and toggle visibility on click of .show_map | |
* | |
*/ | |
add_action( 'wp_head', function() { ?> | |
<style> | |
.facetwp-facet-map {display: none; } | |
</style> | |
<script> |
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_facet_html', function( $output, $params ) { | |
if ( 'my_facet' == $params['facet']['name'] ) { // change 'my_facet' to name of your facet | |
$output = str_replace ( '</select>' , '</select><button onclick="FWP.refresh()">>></button>' , $output ); | |
} | |
return $output; | |
}, 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 | |
$selected_alpha = ''; | |
if ( isset( FWP()->facet->facets['titles']['selected_values'] ) ) { | |
$alpha = FWP()->facet->facets['titles']['selected_values']; | |
$selected_alpha = array_shift( $alpha ); | |
} | |
while ( have_posts() ) : the_post(); ?> | |
<div id="downloads"> |
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 | |
/** | |
* replace "Update" for search button with different text | |
* change 'autocomplete_facet' to the name of your facet | |
* Note that this text is also translation ready and could be | |
* modified using internationalization functions as well | |
*/ | |
add_filter( 'facetwp_facet_html', function( $output, $params ) { | |
if ( 'autocomplete_facet' == $params['facet']['name'] ) { |
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 facet name | |
if ( 0 !== $params['depth'] ) { | |
// lookup parent terms | |
$ancestors = get_ancestors( $params['facet_name'], 'name_of_taxonomy', 'taxonomy' ); // 'name_of_taxonomy' to name of taxonomy | |
$starting_depth = $params['depth']; | |
foreach ( $ancestors as $ancestor ) { | |
$term = get_term( $ancestor, 'name_of_taxonomy' ); // 'name_of_taxonomy' to name of taxonomy |
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_facet_render_args', function( $args) { | |
if ( 'my_search_facet' == $args['facet']['name'] ) { // change my_search_facet to name of your facet | |
$args['facet']['placeholder'] = 'Something'; | |
} | |
return $args; | |
} ); |
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 | |
/** index a serialized checkbox | |
** run reindex after adding code to your site | |
**/ | |
add_filter( 'facetwp_index_row', function( $params, $class ) { | |
if ( 'my_facet' == $params['facet_name'] ) { // change my_facet to name of your facet | |
$values = maybe_unserialize( $params['facet_value'] ); | |
if ( is_array( $values ) && ! empty( $values ) ) { | |
foreach ( $values as $value ) { |
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 | |
/** | |
* updates et_pb_column_single for divi on facet load | |
*/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if ( $( '.et_section_specialty' ).length ) { | |
$( '.et_section_specialty' ).each( function() { |
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; |
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 | |
// re-index your facets after adding this code | |
add_filter( 'facetwp_index_row', function( $params, $class ) { | |
if ( 'author' == $params['facet_name'] ) { | |
$user = get_user_by( 'login', $params['facet_display_value'] ); | |
if ( false !== $user ) { | |
$params['facet_display_value'] = $user->last_name . ', ' . $user->first_name | |
} | |
} | |
return $params; |