Skip to content

Instantly share code, notes, and snippets.

View DavidCramer's full-sized avatar

David Cramer DavidCramer

View GitHub Profile
<?php
if ( ! have_posts() ) {
echo 'Nothing, sorry.';
return;
}
?>
<table>
<thead>
@DavidCramer
DavidCramer / facet.php
Created February 27, 2017 05:22 — forked from anonymous/facet.php
Facet
<div class="facetwp-wrapper">
[facetwp facet="make"][facetwp facet="keyword"]
<div class="facetwp-template"></div>
</div>
<?php
/**
* The template for displaying product content in the single-product.php template
*
* Override this template by copying it to yourtheme/woocommerce/content-single-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
function cspm_display_single_product_map(){
echo do_shortcode('[facetwp map="true"]');
}
add_action('woocommerce_after_single_product_summary', 'cspm_display_single_product_map', 15);
@DavidCramer
DavidCramer / custom.js
Last active February 6, 2017 05:57 — forked from mgibbs189/test.js
FacetWP - Set "sort by" when specific facet is used
(function($) {
$(document).on('facetwp-refresh', function() {
if( FWP.extras['sort'] !== 'default' ){
return;
}
if ( FWP.facets['baby_sitter_cost'].length ) {
FWP.extras['sort'] = 'cost';
}else if ( FWP.facets['age'].length ) {
FWP.extras['sort'] = 'age';
}else if ( FWP.facets['experience'].length ) {
function my_facetwp_index_row( $params, $class ) {
if ( 'branch' == $params['facet_name'] ) {
$values = (array) $params['facet_value']; // an array of post IDs (it's already unserialized)
foreach ( $values as $val ) {
$params['facet_value'] = the_field( 'martygeocoderlatlng', $val );
$params['facet_display_value'] = the_field('martygeocoderaddress', $val);
$class->insert( $params ); // insert each value to the database
}
// skip the default indexing query
return false;
@DavidCramer
DavidCramer / output
Created December 6, 2016 09:51 — forked from mikeTierney19/output
changing $output
function my_facetwp_facet_html( $output, $params ) {
if ( 'monthly_tags' == $params['facet']['name'] ) {
$output = '
<div class="facetwp-checkbox" data-value="january-2017">
January 2017
<span class="facetwp-counter">(1)</span>
</div>
<div class="facetwp-checkbox" data-value="february-2017">
February 2017
<span class="facetwp-counter">(1)</span>
<?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