Skip to content

Instantly share code, notes, and snippets.

View bpmore's full-sized avatar

Brent Passmore bpmore

View GitHub Profile
@srobbin
srobbin / gist:3799775
Created September 28, 2012 13:15
Random Backstretch image
<script>
// Create an array of images that you'd like to use
var images = [
'image1.jpg'
, 'image2.jpg'
, 'image3.jpg'
];
// Get a random number between 0 and the number of images
var randomNumber = Math.floor( Math.random() * images.length );
@isGabe
isGabe / get-highlight-terms.php
Last active February 12, 2022 16:22
WordPress: Output a list of taxonomy terms, then highlight the terms the belong to the current post. Updated to use in_array() to add a "current" CSS class to terms that the current post has. This way we don't have to worry about keeping up with terms in the CSS. Hooray for logic! #snippet #WordPress
<?php
/*
As the title implies, this will give you a way to
1. output a complete list of terms for a given taxonomy (nothing special there)
2. highlight the terms that the current post has (the magic!)
Probably need to figure out a better way to echo out the url of the term archive page...
*/
@grtaylor2
grtaylor2 / gist:5960970
Created July 9, 2013 20:26
Code to DELETE from home.php file to remove blog posts from Genesis Minimum home page layout.
add_action( 'genesis_loop', 'minimum_grid_loop_helper' );
function minimum_grid_loop_helper() {
if ( function_exists( 'genesis_grid_loop' ) ) {
genesis_grid_loop( array(
'features' => 0,
'feature_image_size' => 'featured',
'feature_image_class' => 'post-image',
'feature_content_limit' => 0,
'grid_image_size' => 0,
@kisabelle
kisabelle / wp-assign-parent-template.php
Created January 22, 2014 19:04
WordPress: Automatically Apply Parent Page Template to Child Pages by Matovu Richard
<?php
function switch_page_template() {
global $post;
// Checks if current post type is a page, rather than a post
if (is_page())
{
// Checks if page is parent, if yes, return
if ($post->post_parent == 0)
return true;
else if ($post->post_parent != $post->ID)
@tomfinitely
tomfinitely / gist:65bbd2dc0a660a06b5e7
Created June 3, 2014 15:31
Genesis 2.0 Conditional CSS for Internet Explorers 7 & 8
//* Conditional CSS
add_action( 'wp_enqueue_scripts', 'child_add_ie8_style_sheet', 200 );
function child_add_ie8_style_sheet() {
global $wp_styles;
wp_enqueue_style( 'child-ie8', get_stylesheet_directory_uri() . '/style-ie8.css', array(), '1.0' );
$wp_styles->add_data( 'child-ie8', 'conditional', 'lte IE 8' );
}
add_action( 'wp_enqueue_scripts', 'child_add_ie7_style_sheet', 200 );
function child_add_ie7_style_sheet() {
@bradpotter
bradpotter / style.css
Last active November 3, 2016 16:58
Full Width Slider on Education Pro Theme
.education-pro-home #genesis-responsive-slider {
max-width: 100%;
}
.education-pro-home .flexslider {
max-width: 100%;
}
.education-pro-home .flexslider .slides img {
width: 100%;
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );
@wearehyphen
wearehyphen / hyphen_gravity_forms_date_validation.php
Last active September 12, 2018 21:43
Gravity Forms: Validate Arrival & Departure Dates
/***
* Gravity Forms: Validate to ensure date fields are not the same or todays date
*
* This will validate the fields on form submission and return a validation error on the fields in question.
* In this case it validates an Arrival and Departure date against each other and today's date.
*
* Code goes in your theme's functions.php file.
***/
add_filter('gform_field_validation','validate_dates',10,4);
@srikat
srikat / CSScomb.sublime-settings
Last active June 1, 2017 18:27
Sublime Text CSScomb user settings file for formatting CSS per WordPress coding standards. http://sridharkatakam.com/format-css-per-wordpress-coding-standards-using-csscomb-sublime-text/
{
"config": {
"exclude": [
".git/**",
"node_modules/**"
],
"verbose": true,
"always-semicolon": true,
"block-indent": "\t",
@nickdavis
nickdavis / functions.php
Created February 11, 2015 21:05
Remove blog section from homepage of Education Pro theme by StudioPress
<?php
// Add this to your functions.php file, excluding the opening <?php
add_action( 'wp_head', 'nd_remove_homepage_blog' );
// Remove blog section from homepage
function nd_remove_homepage_blog() {
if ( is_front_page() || is_home() ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
}
}