Skip to content

Instantly share code, notes, and snippets.

Matt Gibbs mgibbs189

Block or report user

Report or block mgibbs189

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mgibbs189
mgibbs189 / functions.php
Created Nov 18, 2019
FacetWP - turn off URL hash functionality
View functions.php
<?php
// Add to your (child) theme's functions.php file
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if (! FWP.loaded) {
@mgibbs189
mgibbs189 / functions.php
Created Nov 15, 2019
User Post Type - force a sync every 8 hours
View functions.php
<?php
add_action( 'mysite_sync_users', [ UPT()->sync, 'run_sync' ] );
if ( ! wp_next_scheduled( 'mysite_sync_users' ) ) {
wp_schedule_single_event( time() + 28800, 'mysite_sync_users' ); // every 8 hours
}
View test.php
<?php
$args = [
'post_type' => 'event',
'post_status' => 'publish',
'posts_per_page' => 4,
'meta_query' => [
[
'key' => 'event_date',
'compare' => '>=',
'value' => date( 'Ymd' )
@mgibbs189
mgibbs189 / functions.php
Created Nov 12, 2019
FacetWP - ignore WP Product Bundles query (when added to cart)
View functions.php
<?php
// Add the following to your (child) theme's functions.php
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( 'product' == $query->get( 'post_type' ) && 'product_query' != $query->get( 'wc_query' ) ) {
$is_main_query = false;
}
return $is_main_query;
}, 10, 2 );
@mgibbs189
mgibbs189 / functions.php
Created Nov 8, 2019
FacetWP - force-remove the fwp-loop HTML comment tag
View functions.php
<?php
add_action( 'init', function() {
remove_action( 'loop_start', [ FWP()->display, 'add_template_tag' ] );
}, 20 );
@mgibbs189
mgibbs189 / functions.php
Last active Nov 8, 2019
FacetWP - WP User Frontend save handler
View functions.php
<?php
// Add the following to your (child) theme's functions.php
add_action( 'wpuf_add_post_after_insert', 'prefix_facetwp_index_post', 100 );
add_action( 'wpuf_edit_post_after_update', 'prefix_facetwp_index_post', 100 );
function prefix_facetwp_index_post( $post_id ) {
if ( function_exists( 'FWP' ) ) {
FWP()->indexer->index( $post_id );
@mgibbs189
mgibbs189 / functions.php
Last active Nov 6, 2019
FacetWP - custom snazzy map design
View functions.php
<?php
add_filter( 'facetwp_map_init_args', function( $settings ) {
$styles = '[{"featureType":"water","elementType":"geometry","stylers":[{"color":"#193341"}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#2c5a71"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#29768a"},{"lightness":-37}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#406d80"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#406d80"}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#3e606f"},{"weight":2},{"gamma":0.84}]},{"elementType":"labels.text.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"administrative","elementType":"geometry","stylers":[{"weight":0.6},{"color":"#1a3541"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#2c5a71"}]}]';
$settings['init']['styles'] = json_decode( $styles );
return $setti
@mgibbs189
mgibbs189 / functions.php
Created Nov 1, 2019
FacetWP - get county name from code
View functions.php
<?php
// Add the following to your (child) theme's functions.php file
// Then re-index afterwards
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'country' == $params['facet_name'] && 2 == strlen( $params['facet_value'] ) ) {
$params['facet_display_value'] = locale_get_display_region( '-' . $params['facet_value'], 'en' );
}
return $params;
@mgibbs189
mgibbs189 / functions.php
Created Oct 23, 2019
FacetWP - recent posts for a specific post format
View functions.php
<?php
$args = [
'posts_per_page' => 10,
'tax_query' => [
[
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-link'
]
@mgibbs189
mgibbs189 / test.js
Last active Oct 22, 2019
FacetWP - show reset button only when facets are selected
View test.js
<script>
/*
Code placement: see the "Javascript" section on https://facetwp.com/how-to-use-hooks/
This assumes that your reset button looks like this:
<a class="my-reset-btn" onclick="FWP.reset()">RESET</a>
*/
(function($) {
You can’t perform that action at this time.