Skip to content

Instantly share code, notes, and snippets.

View joshdavenport's full-sized avatar
🦉
Hooting and Howling

Josh Davenport-Smith joshdavenport

🦉
Hooting and Howling
View GitHub Profile
@joshdavenport
joshdavenport / liquid_showoptions.html
Last active December 21, 2015 00:48
Liquid code for Shopify templates to allow displaying of option variants. Useful if you want to show a list of sizes for a product on a collection page or a list of colours. Can use for any option type, just change the option_handle check.
{% comment %}
Show all sizes for a product in liquid
{% endcomment %}
{% for option in product.options %}
{% assign option_handle = option | handle %}
{% assign option_index = forloop.index0 %}
{% if option_handle == 'size' %}
{% assign values = '' %}
<ul class="{{ option_handle }}-options">
{% for variant in product.variants %}
@joshdavenport
joshdavenport / custom-metabox-fields-pages-functions.php
Last active December 14, 2015 20:09
Example of how to use the Custom Metaboxes and Fields framework for WordPress with pages, hiding the WYSIWYG for pages with managed templates. Better examples of the types of fields are shown here: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress/blob/master/example-functions.php
<?php
/**
* Remove wysiwyg for pages that have theme managed templates
*/
add_action('admin_init', 'fafpp_remove_editor_init');
function fafpp_remove_editor_init() {
if(isset($_GET['post'])) {
$post_id = $_GET['post'];
@joshdavenport
joshdavenport / reloadWithQueryStringVars.js
Created April 21, 2012 09:55
Reload the current page with specified query string variables
function reloadWithQueryStringVars (queryStringVars) {
var existingQueryVars = location.search ? location.search.substring(1).split("&") : [],
currentUrl = location.search ? location.href.replace(location.search,"") : location.href,
newQueryVars = {},
newUrl = currentUrl + "?";
if(existingQueryVars.length > 0) {
for (var i = 0; i < existingQueryVars.length; i++) {
var pair = existingQueryVars[i].split("=");
newQueryVars[pair[0]] = pair[1];
}
@joshdavenport
joshdavenport / gist:957257
Created May 5, 2011 15:32 — forked from paulirish/README.md
imagesLoaded() jquery plugin
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!
// callback function is passed the last image to load
// as an argument, and the collection as `this`