Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
mgibbs189 / functions.php
Last active August 14, 2017 13:03 — forked from anonymous/Ordering depending on distance selection
Ordering depending on distance selection
<?php
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
if ( 0 < count( $class->facets['distance']['selected_values'] ) ) {
$query_args['orderby'] = 'post__in';
$query_args['order'] = 'ASC';
}
return $query_args;
}, 10, 2 );
@mgibbs189
mgibbs189 / custom-loop.php
Last active September 1, 2022 13:25 — forked from SauntValerian/gist:a79845e301de969017e714a96ffee6da
Multiple Loops for FacetWP
<?php
$args = array(
'post_type' => 'location',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'title',
'facetwp' => true,
'tax_query' => array(
array(
'taxonomy' => 'advertiser-level',
@mgibbs189
mgibbs189 / functions.php
Created June 28, 2017 18:21 — forked from DavidCramer/functions.php
Disable mouse scroll on Map
<?php
// add this to your child themes functions.php file
add_filter( 'facetwp_map_init_args', function ( $args ) {
$args['scrollwheel'] = false;
return $args;
} );
<?php /* Template Name: Full Map Facet Search */ ?>
<?php include('content/map-header.php'); // special header for map search page ?>
<div id="#map-page-content-container">
<button id="map-trigger">Search Map</button>
@mgibbs189
mgibbs189 / functions.php
Created June 19, 2017 17:08 — forked from JiveDig/functions.php
Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
<?php
/**
* Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
*
* @uses FacetWP
* @uses WooCommerce Memberships
*/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
<?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
@mgibbs189
mgibbs189 / test.js
Last active April 16, 2021 06:19 — forked from snormand27/gist:da23358fe65c6486634396faab0ee14d
Code used for facetWP reload page loop
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if (FWP.loaded) { // after the initial pageload
FWP.parse_facets(); // load the values
FWP.set_hash(); // set the new URL
location.reload();
return false;
}
});
<?php
remove_action( 'genesis_loop', 'genesis_do_loop');
add_action( 'genesis_loop', 'lofts_floor_plan_loop' );
//* Add filtering sidebar
add_action( 'genesis_before_content', 'floorplan_filters' );
function floorplan_filters() {
@mgibbs189
mgibbs189 / search.php
Last active November 28, 2016 14:22 — forked from anonymous/search.php
<?php
function touteslesbox_fwp_archive_query( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return $query;
remove_filter('pre_get_posts', 'touteslesbox_fwp_archive_query', 1);
if ( $query->is_post_type_archive( 'coupons' ) ) {
@mgibbs189
mgibbs189 / search.php
Last active November 4, 2016 18:35 — forked from anonymous/gist:6ba8da4726df5c35d8fe74751deaca0e
chnetwork search.php
<div id="home-posts" class="container">
<h3 style="margin-top: 40px; margin-bottom: 40px;"><?php wp_title(); ?></h3>
<?php if ( have_posts() ) : ?>
<div class="facetwp-template">
<?php while ( have_posts() ) : the_post(); ?>
<div class="archive-item">