Skip to content

Instantly share code, notes, and snippets.

View emaildano's full-sized avatar
🏄‍♀️
Surfing the information superhighway

Dano emaildano

🏄‍♀️
Surfing the information superhighway
  • Philadelphia, PA
View GitHub Profile
@emaildano
emaildano / JQuery Scroll with Offset.js
Created January 14, 2014 14:52
Enable all anchor links to smoothly scroll with offset
$('a[href*=#]').each(function() {
if($(this).attr('href').indexOf("#") === 0) {
$(this).click(function(e) {
e.preventDefault();
var targetOffset = $($(this).attr('href')).offset().top - 50;
$('body').animate({scrollTop: targetOffset}, 700);
});
}
});
@emaildano
emaildano / Add Class JQuery
Created January 12, 2014 20:19
Add class to target
// add class
$(".target").addClass(".class");
@emaildano
emaildano / filter-by-tax-query.php
Created January 8, 2014 18:52
Custom function and query for filtering by custom taxonomy. Compliments of: @drewgourley via: http://wordpress.stackexchange.com/a/14313
<?php
$args = array (
'orderby' => 'year_published',
'order' => ASC,
);
query_posts($args); ?>
<?php while (have_posts()) : the_post(); ?>
@emaildano
emaildano / Simple ACF Field Condition
Created January 3, 2014 03:40
Simple ACF conditional example.
<?php if(get_field('custom_page_title')) { ?>
<?php the_field('custom_page_title'); ?>
<?php } else { ?>
<?php echo roots_title(); ?>
<?php } ?>
@emaildano
emaildano / 0_reuse_code.js
Created December 27, 2013 18:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@emaildano
emaildano / comma-tax-list.php
Last active January 1, 2016 06:29
Get terms from a custom tax and output plural / single titles and separate them with commas. Also, include an if statement for taxonomies that are empty which would return errors.
<?php
// define category slug and name
$category = 'authors'; // Taxonomy Name
$categoryName = 'Authors'; // Front-end / Plural Name
$categorySingle = 'Author'; // Front-end Singular Name
// end definition
$terms = get_the_terms( $post->ID , $category );
$total = count ($terms);
$i=1;
@emaildano
emaildano / Scroll to top on page load.
Created December 19, 2013 17:26
Scroll the window to top after the page loads.
// scroll to top on page load
$(document).ready(function(){
$(window).scrollTop(0);
});
@emaildano
emaildano / Bootstrap Tab LInks
Created December 19, 2013 17:02
Enable links to open Bootstrap tabs.
$(window).resize(function() {
$('#content').height($(window).height() - 46);
});
$(window).trigger('resize');