Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
mgibbs189 / simple-history-log-http-requests-time.php
Created May 6, 2016 19:19 — forked from bonny/simple-history-log-http-requests-time.php
Snippet for WordPress plugin Simple History Log that logs https request made and how long each request took
<?php
/**
* To use this you first need to install the free plugin Simple History
* https://wordpress.org/plugins/simple-history/
*/
// pre_http_request is fired close before the actual request
add_filter( 'pre_http_request', function( $retval, $r, $url ) {
@mgibbs189
mgibbs189 / gist:a5b88f87b2d4ec657c50f91f09fa4ade
Last active July 4, 2016 15:46 — forked from anonymous/gist:d38254b0d45617c466541a21ec296587
Diane Dopson Properties Query Arguments
<?php
return array(
"post_type" => "property",
"post_status" => "publish",
"orderby" => "meta_value_num",
"meta_key" => "price_no_formatting",
"order" => "DESC",
"posts_per_page" => 20
);
@mgibbs189
mgibbs189 / facetwp-index-row.php
Last active June 8, 2016 14:21 — forked from wpweb101/facetwp-index-row.php
Facetwp Re-indexing EDD - Frontend Submissions checkbox values
<?php
add_filter( 'facetwp_index_row', 'wwce_facetwp_index_row' );
function wwce_facetwp_index_row( $params ) {
if ( 'genre' == $params['facet_name'] || 'instruments' == $params['facet_name'] || 'mood' == $params['facet_name'] ) {
$values = (array) $params['facet_value'];
foreach ( $values as $val ) {
$params['facet_value'] = $val;
$params['facet_display_value'] = $val;
<?php
return array(
"post_type" => array(
"cpt1",
"cpt2"
),
'posts_per_page' => 28,
'orderby' => 'rand',
);
?>
@mgibbs189
mgibbs189 / working-search.php
Last active June 28, 2016 19:50
Working Search
<?php get_header(); ?>
<main id="main" class="body__content main" role="main">
<div class="content__main">
<div class="content__adv-search">
<h3 class="content__adv-search--title">Refine Your Search</h3>
<?php //echo do_shortcode( '[facetwp facet="advanced_search"]' );?>
<p class="content__adv-search--subtitle">Show me only results from:</p>
<?php //echo do_shortcode( '[facetwp facet="refine_results"]' );?>
</div>
<header class="page__header">
<?php
function my_facetwp_index_row( $params, $class ) {
if ( 'keydate' == $params['facet_name'] ) { // 20170823
$val = $params['facet_value'];
$fixed = substr( $val, 0, 4 ) . '-' . substr( $val, 4, 2 ) . '-' . substr( $val, 6, 2 );
$params['facet_value'] = $fixed;
$params['facet_display_value'] = $fixed;
}
return $params;
@mgibbs189
mgibbs189 / gist:4a8e5c0e018e257eceb1d057477b576f
Last active September 19, 2016 23:46
FacetWP - using the facetwp_indexer_post_facet filter
<?php
function lh_fwp_index_coming_soon_facet( $return, $params ) {
$facet_params = $params['defaults'];
if ( 'cf/edd_coming_soon' == $facet_params['facet_source'] ) {
$value = get_post_meta( $facet_params['post_id'], 'edd_coming_soon', true );
$value = empty( $value ) ? 'Available' : 'Coming Soon';
$facet_params['facet_value'] = $value;
$facet_params['facet_display_value'] = $value;
FWP()->indexer->index_row( $facet_params );
<div class="category-navigation">
<div class="container vpadding--top vpadding--xs">
<div class="row">
<div class="col-xs-12">
<?php echo facetwp_display( 'facet', 'adaptation_levels' ); ?>
<?php echo facetwp_display( 'facet', 'search' ); ?>
</div>
</div>
@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">
@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' ) ) {