Skip to content

Instantly share code, notes, and snippets.

@jwebcat
jwebcat / caption-in-swipebox.html
Created April 16, 2014 23:03
swipebox caption demo
<div class="c-gallery">
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png" title="I'm a caption in the title attribute of the a tag">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
<p>I'm an image link that opens a image lightbox gallery</p>
</a>
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png" title="I'm another caption in the title attribute of the a tag">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
</a>
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png" title="I'm yet another caption in the title attribute of the a tag">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
@jwebcat
jwebcat / lightbox.html
Created April 14, 2014 23:05
lightbox examples
<div class="c-gallery">
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
<p>I'm an image link that opens a image lightbox gallery</p>
</a>
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
</a>
<a rel="gallery-1" class="swipebox" href="/wp-content/uploads/2014/01/air_conditioner.png">
<img src="/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
<div class="c-gallery">
<a rel="gallery-1" class="swipebox" href="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png">
<img src="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
</a>
<a rel="gallery-1" class="swipebox" href="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png">
<img src="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
</a>
<a rel="gallery-1" class="swipebox" href="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png">
<img src="http://local.wordpress-trunk.dev/wp-content/uploads/2014/01/air_conditioner.png" alt="image">
</a>
@jwebcat
jwebcat / posts-nav-thumbs-wp.php
Created February 2, 2014 11:11
previous next post links with thumbnails wp --> goes inside post loop
<div id="cooler-nav" class="navigation">
<?php
$prevPost = get_previous_post(true);
if($prevPost) : ?>
<div class="nav-box previous">
<?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100) ); ?>
<?php previous_post_link('%link',"$prevthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php endif; ?>
<?php
@jwebcat
jwebcat / add-back-as-post.php
Created January 31, 2014 10:57
remove cpt tax from url
/**
* Some hackery to have WordPress match postname to any of our public post types
* All of our public post types can have /post-name/ as the slug, so they better be unique across all posts
* Typically core only accounts for posts and pages where the slug is /post-name/
*/
function vipx_parse_request_tricksy( $query ) {
// Only noop the main query
if ( ! $query->is_main_query() )
return;
@jwebcat
jwebcat / cfix.scss
Created January 31, 2014 06:28
cfix extend
%cfix {
&:before,
&:after {
content:"";
display: table;
}
&:after {
clear:both;
}
& {
@jwebcat
jwebcat / resize-fun.js
Created January 26, 2014 08:17
function to do cool stuff on resize - variable are stored in the body:after attribute
$(function() {
var currentSize = "kitty"; // null var so its never the current size to start
$(window).resize(function() {
var size = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
var $menu = $('.nav-collapse');
/* Ridiculous thing to deal with inconsistent returning of
@jwebcat
jwebcat / auto-coupon-woo.php
Created January 24, 2014 08:20
Automatically apply coupon to cart WooCommerce
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
function apply_matched_coupons() {
global $woocommerce;
$get1 = 'getonech'; // your coupon code here
$get2 = 'gettwoch'; // your coupon code here
$get3 = 'getthreech'; // your coupon code here
$get4 = 'getfourch'; // your coupon code here
$get5 = 'getfivech'; // your coupon code here
@jwebcat
jwebcat / cpt-tags-cats-boxes.php
Created January 24, 2014 08:19
Add category and tag boxes to custom post type admin edit screen WP
add_action('init', 'demo_add_default_boxes');
function demo_add_default_boxes() {
register_taxonomy_for_object_type('category', 'fonts');
register_taxonomy_for_object_type('post_tag', 'fonts');
}
@jwebcat
jwebcat / cpt-to-main-loop.php
Created January 24, 2014 08:18
Add custom post types to pre_get_posts for main loop WP
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_category() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'page', 'fonts' ) );
return $query;
}