Skip to content

Instantly share code, notes, and snippets.

@keithdevon
keithdevon / relevanssi-custom-functions.php
Last active January 25, 2024 12:51
Relevanssi job search
// filter relevanssi based on job_region query
add_filter('relevanssi_modify_wp_query', 'region_tax_query');
function region_tax_query($query) {
$tax_query = array();
if (!empty($query->query_vars['job_region'])) {
$tax_query[] = array(
'taxonomy' => 'region',
'field' => 'id',
'terms' => $query->query_vars['job_region']
@keithdevon
keithdevon / allow-region.php
Created October 7, 2014 10:41
Allow region query in Relevanssi search
// add region query variable
add_filter('query_vars', 'introduce_region_qv');
function introduce_region_qv($qv) {
$qv[] = 'job_region';
return $qv;
}
// filter relevanssi based on job_region query
@keithdevon
keithdevon / cache-busting-script.php
Created November 20, 2014 15:56
WordPress script and style cache busting!
add_action('wp_enqueue_scripts', 'load_your_css');
function load_your_css(){
if(!is_admin()){
$css_link = get_stylesheet_directory_uri() . '/style.css';
$css_file = get_stylesheet_directory() . '/style.css';
wp_enqueue_style('theme-style', $css_link, array(), filemtime($css_file), 'all');
}
}
@keithdevon
keithdevon / add_link_to_custom_excerpts
Created January 15, 2015 11:02
Add read more link to custom excerpts
@keithdevon
keithdevon / svg-img.html
Created May 13, 2015 13:29
SVG image with PNG fallback
<img src="tomato.svg" onerror="this.src='tomato.png'; this.onerror=null;">
@keithdevon
keithdevon / plugin-template.php
Created August 20, 2015 10:07
WordPress Plugin template with conditional style/script loading
<?php
/*
Plugin Name: Plugin Name
Description: Description
Version: 0.1
Author: White Rock Design
Author URI: http://keithdevon.com
*/
// block direct access
@keithdevon
keithdevon / _layout.scss
Last active March 27, 2018 09:53
Adds breakpoint debugging output when using Neat 2 grid system
/*
* Layout debugging display
*/
body {
&.env--local {
&:after {
content: 'default';
position: fixed;
bottom: 0;
right: 0;
<?php
/**
* This function appends a class to the body depending on the environment.
*
* @param array $classes current body classes.
*
* @return array $classes any modification to the class array.
*/
function tgf_add_environment_class( $classes ) {
@keithdevon
keithdevon / _layout.scss
Last active March 27, 2018 09:55
Updated _layout.scss file to output all Neat grid settings at each breakpoint
/*
* Layout debugging display
*/
body {
&.env--local {
.site-wrapper {
&:after {
content: 'default';
position: fixed;