Skip to content

Instantly share code, notes, and snippets.

View isGabe's full-sized avatar
👨‍💻
:party-code:

Gabriel Luethje isGabe

👨‍💻
:party-code:
View GitHub Profile
@isGabe
isGabe / cpt-archive-by-tax-term.php
Last active December 18, 2015 10:49
WordPress: CPT Archive Organized by Taxonomy Term #snippet #WordPress
<?php
$tax_name = 'tax_name';
$terms = get_terms($tax_name);
$count = count($terms);
if ( $count > 0 ){
foreach ( $terms as $term ) {
echo '<section class="' . $term->name . '">';
echo '<h2 class="section-title">' . $term->name . '</h2>';
echo '<ul>';
@isGabe
isGabe / gravity-forms.scss
Created June 13, 2013 19:54
WordPress: Gravity Forms stylesheet, somewhat SASSified #WordPress #snippet
/*
----------------------------------------------------------------
Gravity Forms Front End Form Styles
Version 1.7
http: //www.gravityforms.com
updated: April 22, 2013 5:19 PM
*/
@isGabe
isGabe / wp-enqueue-gravity-forms-css.php
Created June 13, 2013 19:59
WordPress: register Gravity Forms stylsheet, only enqueue on Contact page #snippet #WordPress
// Gravity Forms style sheet
wp_register_style( 'gravity-forms', get_stylesheet_directory_uri() . '/library/css/gravity-forms.css', array(), '' );
// only load on contact page
if(is_page('contact')){
wp_enqueue_style('gravity-forms');
}
@isGabe
isGabe / acf-gallery-grid.php
Created June 13, 2013 21:34
WordPress: Output Avdanced Custom Fields Gallery Grid #WordPress #snippet
@isGabe
isGabe / mobile-menu-toggle.js
Created June 13, 2013 22:42
jQuery/CSS: Basic mobile menu toggle using, with nested CSS toggle for dropdowns
$('#menu-main-menu').slideToggle(200);
});
$('#menu-main-menu > li.menu-item-parent > a').click(function(e){
$(this).parent().toggleClass('open');
$(this).preventDefault();
});
@isGabe
isGabe / menu-item-parent-class.php
Created June 13, 2013 22:47
WordPress: Add 'menu-item-parent' to menu lis that contain submenus #WordPress #snippet
/**
* Set our new walker only if a menu is assigned,
* and a child theme hasn't modified it to one level deep
*/
function fstop_nav_menu_args( $args ) {
if ( 1 !== $args[ 'depth' ] && has_nav_menu( 'main-nav' ) ) {
$args[ 'walker' ] = new FStop_Page_Navigation_Walker;
}
return $args;
}
@isGabe
isGabe / widgets.php
Created June 17, 2013 20:25
Basic WordPress Widget Code #snippet #WordPress
<?php
/*
* Basic WordPress Widget Code
* Save to: /wp-content/theme/widgets.php
* in functions.php or appropriate place: if ($wp_version >= 2.8) require_once(TEMPLATEPATH.'/widgets.php');
*
*/
class MyWidgetName extends WP_Widget
{
@isGabe
isGabe / wordpress-force-login.php
Created June 21, 2013 16:10
WordPress: force log in to view any page, with redirect to requested URL#snippet #WordPress
<?php
/*
* Password protect a WordPress site, with a redirect to the requested URL after successful login
*
* Based on:
* http://wordpress.stackexchange.com/a/64999
* http://kovshenin.com/2012/current-url-in-wordpress/
*
**/
@isGabe
isGabe / wp-attachment-gallery.php
Created July 4, 2013 19:27
WordPress: Output all attached images as a gallery #snippet #WordPress
@isGabe
isGabe / wp-pagination.php
Created August 7, 2013 04:37
WordPress: Pagination #snippets #WordPress
<?php
// Numeric Page Navigation
function bones_page_navi() {
global $wp_query;
$bignum = 999999999;
if ( $wp_query->max_num_pages <= 1 )
return;
echo '<nav class="pagination">';