Skip to content

Instantly share code, notes, and snippets.

@csknk
csknk / responsive-equal-column-heights.js
Last active December 24, 2015 23:39
jQuery to set two column heights equal to the height of the largest. Handy when adding borders to parallel columns and a small amount of content in one column can result in an incomplete looking border. Adjusts when browser re-sizes. Height doesn't equalise below a set browser width - because columns stack on top of one another at this point (th…
jQuery(document).ready(function($){
//for old IE browser people
if(jQuery.support.opacity == false){
//If opacity is false, it's assumed that the browser is <= IE8
//In this case, the site is not responsive for these browsers &
//columns are set to the height of the greatest column in all cases
if( $( '.half' ).height() > $( '.half_right' ).height()) {
@csknk
csknk / 0_reuse_code.js
Created October 8, 2013 09:45
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
@csknk
csknk / WP_excerpts_on_pages
Last active December 24, 2015 23:39
Enable excerpts on WordPress pages
/***Enable Excerpts on Pages***/
add_action('init', 'page_excerpts');
function page_excerpts() {
add_post_type_support( 'page', 'excerpt' );
}
@csknk
csknk / add category page title
Created October 8, 2013 09:53
Add category page title (WordPress)
/***Category Page Title****/
function add_category_page_title() {
$cat = get_category( get_query_var( 'cat' ) );/* gets the category info of the current archive page*/
$cat_name = $cat->name; /*pass the value of the category to name, and attach this to the variable*/
?><h2>Articles categorised as: <?php echo $cat_name;?></h2> /*build the headline*/
@csknk
csknk / Related content ACF Thesis 2.1
Last active December 24, 2015 23:49
Add related content to person post type in Thesis 2.1. using the ACF plugin
@csknk
csknk / Tidy Dashboard
Created October 8, 2013 10:53
Tidy up WP dashboard widgets.
/***Tidy Up Dashboard widgets***/
function disable_dashboard_widgets() {
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
@csknk
csknk / ACF Repeater Field Download List
Created October 8, 2013 15:59
Add files for download as a ul. Refers to repeater field from the Advanced Custom Fields plugin for WordPress. Hook code is for the Thesis 2.1 framework. For the repeater field "worksheets" and subfields "upload" (the file for download), "upload_title" (the title for the download link) and "filesize" (so that filesize can be displayed on the dow…
/****ADD REPEATER FIELD FOR UPLOADED FILES****/
function add_project_downloads() {
if(get_field('worksheets')): ?>
<h3 class="no_top_margin">Download Worksheets for this Lesson</h3>
<ul>
<?php while(has_sub_field('worksheets')): ?>
@csknk
csknk / ACF related content ul
Created October 8, 2013 16:08
Add related content as a UL. Data comes form the "Relationship" field type in the WordPress Advanced Custom Fields plugin, return format set as "post objects". Hook code is for Thesis 2.1 WP framework.
<?php
// fancy PHP 5.3+ style
add_action( 'template_redirect', function() {
if ( ! is_user_logged_in() ) {
wp_redirect( wp_login_url() );
exit;
}
} );
//********************************************************
// function for calculating heights
//********************************************************
function equalHeight(group) {
var tallest = 0;
group.each(function() {
var thisHeight = jQuery(this).height();
if(thisHeight > tallest) {
tallest = thisHeight;