Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
<?php
function add_filters($tags, $function) {
foreach($tags as $tag) {
add_filter($tag, $function);
}
}
function roots_rewrites() {
/**
* Define helper constants
(function() {
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
notify: {
watch: {
options: {
title: 'Who watches the watchmen?',
@ebinnion
ebinnion / slider.js
Last active January 2, 2016 12:19
This gist demonstrates how to build a basic testimonials fade in and fade out.
jQuery(document).ready(function($){
var testimonials = $('aside .testimonials .testimonial');
var current = 0;
function slide(){
intv = setInterval(function() {
$(testimonials[current]).fadeOut('slow', function(){
if( typeof testimonials[current+1] != 'undefined') {
current += 1;
@ebinnion
ebinnion / bootstrap_wp_link_pages.php
Last active March 14, 2017 10:02
Extends the WordPress wp_link_pages function in order to style the page links with Bootstrap's classes.
.equiwidth {
text-align: justify;
line-height: .5em;
padding-top: .25em;
line-height: 0;
* {
display: inline;
}
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .lt-ie9 .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@ebinnion
ebinnion / index.html
Created September 3, 2013 15:40
Foundation Starter
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Foundation 4</title>
<!-- If you are using CSS version, only link these 2 files, you may add app.css to use for your overrides if you like. -->
@ebinnion
ebinnion / edd-custom-license.php
Last active December 21, 2015 18:39
This is a fully functioning WordPress plugin for Easy Digital Downloads that we use to allow users to choose between year or lifetime licenses. This assumes you are selling a singular product.
<?php
/*
* Plugin Name: EDD License Filter
* Description: Allows us to change license lengths based on pricing options.
* Author: Eric Binnion
* Version: 0.1
*/
// This snippet adapted from https://easydigitaldownloads.com/docs/changing-license-expiration-length/

Ok, I got there at the end. I couldn't use WP_Query class as I really needed to have my own pretty big and complex SQL. Here is what I ended up having:

In functions.php I have my custom SQL and logic for counting the values needed for the WP pagination logic:

function vacancies_current( ){
    global $wpdb, $paged, $max_num_pages, $current_date;

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $post_per_page = intval(get_query_var('posts_per_page'));

$offset = ($paged - 1)*$post_per_page;