Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
mgibbs189 / test.php
Created September 25, 2015 00:30
FacetWP - index EDD FES (Front End Submissions) multi-select values
<?php
function index_EDD_FES_multiselect( $params, $class ) {
if ( 'product_style' == $params['facet_name'] ) {
$choices = explode( '| ', $params['facet_display_value'] );
foreach ( $choices as $choice ) {
$params['facet_value'] = $choice;
$params['facet_display_value'] = $choice;
$class->insert( $params );
}
@mgibbs189
mgibbs189 / test.js
Last active September 29, 2015 13:39
FacetWP - store post IDs into a cookie
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
var cookie_data = JSON.stringify(FWP.settings.post_ids);
setCookie("fwp_posts", cookie_data, 7);
});
})(jQuery);
function setCookie(cname, cvalue, exdays) {
var d = new Date();
@mgibbs189
mgibbs189 / test.js
Created September 29, 2015 15:29
FacetWP - generate prev/next buttons from cookie data
<div class="nav-wrapper"><!-- placeholder --></div>
<script>
(function($) {
$(function() {
var post_id = <?php echo $post->ID; ?>; // grab the current post ID
var data = getCookie('fwp_posts'); // get the cookie
if ('' != data) {
data = JSON.parse(data);
var pos = data.indexOf(post_id);
@mgibbs189
mgibbs189 / test.js
Created October 5, 2015 12:20
RT Theme fade support
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
$('.product_boxes .box').addClass('fadeIn animated');
});
})(jQuery);
</script>
@mgibbs189
mgibbs189 / test.php
Last active October 5, 2015 12:54
facetwp_facet_filter_posts to override slider logic
<?php
function custom_slider_logic( $response, $params ) {
$facet = $params['facet'];
// Change the facet name
if ( 'YOUR_FACET_NAME' == $facet['name'] ) {
global $wpdb;
$values = $params['selected_values'];
<?php
function my_facetwp_is_main_query( $is_main_query, $query ) {
if ( isset( $query->query_vars['post_type'] ) ) {
if ( 'edd_wish_list' == $query->query_vars['post_type'] ) {
$is_main_query = false;
}
}
return $is_main_query;
}
<?php while ( have_posts() ): the_post(); ?>
<?php get_template_part('template_sections-dress_grid'); ?>
<?php endwhile; ?>
^[-]?([1-8]?\d(\.\d+)?|90(\.0+)?),[-]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$
@mgibbs189
mgibbs189 / test.php
Last active October 12, 2015 10:45
FacetWP - facetwp_filtered_post_ids get coordinates
<?php
function fwp_get_post_coords( output, $class ) {
$coords = array();
$post_ids = (array) $class->query_args['post__in'];
foreach ( $post_ids as $post_id ) {
$coords[ $post_id ] = array(
'title' => get_the_title( $post_id ),
'lat' => GET_THE_LATITUDE( $post_id ),
@mgibbs189
mgibbs189 / gist:6f773a963ceecfb380e5
Created October 13, 2015 15:13
Listify - order by distance by default
<?php
return array(
'post_type' => 'job_listing',
'posts_per_page' => 18,
'post_status' => 'publish',
'orderby' => 'post__in',
'order' => 'ASC'
);