Skip to content

Instantly share code, notes, and snippets.

@bmodena
bmodena / gist:30284c6eaf6d16dac847
Created February 18, 2015 16:30
Advanced Custom Field - Image Field - Get Cropped image
/*
** ACF Image Helper
**
** @Param $imageId: int - image ID you are using
** @Param $size: string - image size you want to retrieve
** @Param $fieldName: string (optional) - name of the image field within the repeater
** @Return Array - image url and alt text for image
**
*/
function tmbr_get_cropped_image( $imageId, $size ) {
@bmodena
bmodena / wp_query.php
Last active November 18, 2015 19:49
Wordpress WP_Query Sample of custom post type products
<?php
// Get all products
$args = array(
'posts_per_page' => -1,
'post_type' => 'products',
'orderby' => 'menu_order',
'order' => 'ASC',
'no_found_rows' => true
);
@bmodena
bmodena / shopify-flexslider.liquid
Last active October 19, 2022 02:29
Shopify Flexslider Integration with theme settings
<!-- add to head of your theme.liquid after moving the files into the assets folder | https://www.woothemes.com/flexslider/ -->
<!-- add only if you theme is not already including Jquery-->
{{ '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' | script_tag }}
<!-- FLEX Slider css and .js -->
{{ 'flexslider.css' | asset_url | stylesheet_tag }}
{{ 'jquery.flexslider.js' | asset_url | script_tag }}
<!--
add to schema json
@bmodena
bmodena / wp_transient.php
Created February 10, 2016 17:07
wordpress transient
<?php
/* Credit Scotch.io : https://scotch.io/tutorials/a-guide-to-transients-in-wordpress */
// Set variable for debugging
$usecache = true;
// Check if transient exists - use if it does
$projects = get_transient( 'tmbr_cached_projects' );
if ( false === $projects || false === $usecache ) {
@bmodena
bmodena / shopify-remove-relatedtags.liquid
Last active July 22, 2016 14:40
Exclude tags from collection.liquid filter when using tags to show related prodcuts
{% comment %}
Based on using Tags to show related products.
Credit : http://twigs.club/library/hand-picked-related-products-using-tags-or-metafields
{% endcomment %}
<div class="collection-sort">
<label for="SortBy" class="collection-sort__label">{{ 'collections.sorting.title_tags' | t }}</label>
<select name="SortTags" id="SortTags" class="collection-sort__input">
{% if collection.handle %}
<option value="/collections/{{ collection.handle }}">{{ 'collections.sorting.all_of_collection' | t: collection: collection.title }}</option>
@bmodena
bmodena / wp_featured_image_feed.php
Created June 16, 2016 14:41
Wordpress Featured Image in RSS Feed
@bmodena
bmodena / wp-bootstrap-grid_shortcode.php
Created June 21, 2016 15:12
Boostrap Grid / Cols Short Codes
/*
* BOOSTRAP GRID SHORT CODES
* Req : Bootstrap - http://getbootstrap.com/
* add this code to functions.php or a shortcodes.php include
* Use in WISIWIG
---------------------------------------------
[one_third] Content third [/one_third]
[one_third] Content third [/one_third]
[one_third] Content thrid [/one_third]
@bmodena
bmodena / analytics-event.js
Last active February 22, 2017 18:34
Simple analytics event tracking
/*
Add a data attr of event to a tag and push to analytics
@req : jquery
*/
<a href="http://google.com" class="btn" data-event="footer-action">Download Now</a>
<script type="text/javascript">
@bmodena
bmodena / shopify-discount-from-cookie.js
Last active May 2, 2019 10:08
Add discount code to checkout from URL
@bmodena
bmodena / shopify-clearcart.js
Last active September 21, 2022 19:19
Shopify Clear Cart Cookie on logout
/*
@require
Jquery: https://jquery.com/
*/
function delete_cookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
// logout link