Skip to content

Instantly share code, notes, and snippets.

View git-willie's full-sized avatar

Willie git-willie

View GitHub Profile
@git-willie
git-willie / custom-excerpt.php
Created December 14, 2016 19:24
// Custom Excerpt
// Custom Excerpt
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt) . ' …';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
@git-willie
git-willie / load-ajax-content.php
Created November 29, 2016 20:12
[Wordpress] Load content via Ajax
// *** Load gallery on division template via Ajax ***
function load_ajax_content () {
$pid = array( 'p' => $_POST['post_id'], 'post_type' => 'gallery' );
$the_query = new WP_Query( $pid );
if ($the_query->have_posts()) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$images = get_field('photos');
<div class="social-share-btns">
<span style="display: inline-block">Share</span>
<a href="https://www.facebook.com/sharer/sharer.php?u={{product.url}}&title={{product.title}}" onclick="window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"><i class="fa fa-facebook-square"></i></a>
<a href="http://twitter.com/home?status={{ product.title }}+{{shop.url}}{{product.url}}" onclick="window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"><i class="fa fa-twitter"></i></a>
<a href="http://pinterest.com/pin/create/bookmarklet/?media=https:{{ product.featured_image | product_img_url: 'grande' }}&url={{shop.url}}{{product.url}}&is_video=false&description={{ product.title }}" onclick="window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"><i class="fa fa-pinterest"></i></a>
<a href="https://plus.google.com/share?url={{shop.url}}{{product.url}}" oncl
<ul class="top-tier no-bullets">
{% for link in linklists.shop.links %}
{% assign second_tier_list_handle = link.title | handleize %}
{% if linklists[second_tier_list_handle].links != blank %}
<li class="grid__item{% if link.active %} site-nav--active{% endif %}">
<span class="h4 grid__item">{{ link.title }}</span>
<ul class="second-tier no-bullets">
{% for secondTierLink in linklists[second_tier_list_handle].links %}
{% assign third_tier_list_handle = secondTierLink.title | handleize %}
@git-willie
git-willie / related-products-by-product-handle.liquid
Created November 29, 2016 19:04
Related products by using tag with a product handle. For example, related-hdmi-cable
@git-willie
git-willie / variant-specs.liquid
Created November 29, 2016 01:09
Break down each product variant into a label and value
{% unless item.variant.title contains 'Default' %}
{% for i in (1..item.product.options.size) %}
<small class="specs">
{% case i %}
{% when 1 %}
<span>{{ item.product.options.first }}</span> {{ item.variant.option1 }}
{% when 2 %}
{% if item.product.options.size == 2 %}
<span>{{ item.product.options.last}}</span> {{ item.variant.option2 }}
{% else %}