Skip to content

Instantly share code, notes, and snippets.

View treeWater's full-sized avatar

Peter SC treeWater

View GitHub Profile
@treeWater
treeWater / functions.php
Created April 4, 2025 10:41 — forked from alexander-young/functions.php
Defer Javascript in WordPress
function defer_parsing_of_js($url)
{
if (is_admin()) return $url; //don't break WP Admin
if (false === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return str_replace(' src', ' defer src', $url);
}
add_filter('script_loader_tag', 'defer_parsing_of_js', 10);
function repeater_tax_results($categories, $query) {
if ('kiujhhjkhjku' == $query->get('post_type')) {
$categories = array();
$category_query = new WP_Term_Query(array(
'taxonomy' => 'category', // Change 'category' to the taxonomy you want to query.
'hide_empty' => false,
'exclude' => get_cat_ID('Uncategorized'), // Exclude the 'Uncategorized' category
));
function load_splide_scripts() {
wp_register_script('splide-js', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/js/splide.min.js', array(), '4.1.4', true);
wp_register_style('splide-css', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/css/splide.min.css', array(), '4.1.4');
if (is_front_page()) {
wp_enqueue_script('splide-js');
wp_enqueue_style('splide-css');
}
}
add_action('wp_enqueue_scripts', 'load_splide_scripts');
@treeWater
treeWater / functions.php
Created October 23, 2021 03:34 — forked from agusmu/functions.php
WooCommerce - Add Box Frame to Product Image
/* Wrap product image with a box container. */
add_action('prima_custom_scripts', 'prima_custom_product_image_box');
function prima_custom_product_image_box() {
echo 'jQuery(document).ready(function($) {';
echo '$(".woocommerce ul.products li.product a img, .woocommerce-page ul.products li.product a img").wrap("<div class=\'product-image-box\'></div>");';
echo '$(".woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale").each(function() { var item = $(this); item.prependTo(item.parent().find(".product-image-box")); });';
echo '});';
echo "\n";
}
@treeWater
treeWater / Contract Killer 3.md
Created March 6, 2018 00:11
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@treeWater
treeWater / hierarchy.php
Created September 22, 2017 16:30 — forked from johnbillion/hierarchy.php
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Template Hierarchy (as of WordPress 4.8)
is_404() -------------------------------------------------------------------------------------------------> 404.php
is_search() ----------------------------------------------------------------------------------------------> search.php
is_front_page() ------------------------------------------------------------------------------------------> front-page.php
is_home() ------------------------------------------------------------------------------------------------> home.php
@treeWater
treeWater / wp-query-ref.php
Created March 17, 2017 02:09 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
<?php
/**
* Blog Intro
*
*/
function be_blog_intro() {
$content = get_post( get_option( 'page_for_posts' ) )->post_content;
if( $content )
echo '<div class="blog-intro">' . wpautop( $content ) . '</div>';
@treeWater
treeWater / class-custom-featured-post.php
Created February 22, 2017 15:23 — forked from srikat/class-custom-featured-post.php
Custom Featured Post Widget plugin: Skeleton for amending the output of the Genesis Featured Post widget.
<?php
/**
* Plugin Name
*
* @package Custom_Featured_Post_Widget
* @author Gary Jones
* @license GPL-2.0+
* @link http://gamajo.com/
* @copyright 2013 Gary Jones, Gamajo Tech
*/
@treeWater
treeWater / gist:f42128bed3208a60323dbad52dfbab80
Created February 22, 2017 01:56 — forked from billerickson/gist:2040968
Grid Loop using post class
<?php
/**
* Archive Post Class
* @since 1.0.0
*
* Breaks the posts into three columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*
* @param array $classes