Skip to content

Instantly share code, notes, and snippets.

View ChrisCree's full-sized avatar

Chris Cree ChrisCree

View GitHub Profile

Keybase proof

I hereby claim:

  • I am chriscree on github.
  • I am chriscree (https://keybase.io/chriscree) on keybase.
  • I have a public key ASBg0gh-qMpcMeIa5fx4dKQpWtD3xKxp2deSgg_J3Qe4qwo

To claim this, I am signing this object:

@ChrisCree
ChrisCree / functions.php
Created April 26, 2016 00:37
Add the Shop page breadcrumb to single products and archives for WooCommerce pages with the Genesis framework. Code below can be added to your child theme's functions.php file. Then go to Genesis --> Theme Settings and ensure the Breadcrumbs settings for Posts and Archives is enabled. PLEASE NOTE: This code assumes the Genesis Connect for WooCom…
<?php
// Do not copy opening PHP tag above
// Add the Shop page to Genesis breadcrumbs in WooCommerce
// NOTE: Assumes Genesis Connect for WooCommerce plugin is active
add_filter( 'genesis_archive_crumb', 'wsm_prepend_shop_link', 11, 2 );
add_filter( 'genesis_single_crumb', 'wsm_prepend_shop_link', 11, 2 );
function wsm_prepend_shop_link( $crumb, $args ) {
if ( is_singular( 'product' ) || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
@ChrisCree
ChrisCree / genesis_accessible_styles.css
Created April 22, 2016 03:57
Genesis accessibility CSS for quick reference along with PHP code to add theme support for HTML5 markup, mobile viewport, and accessibility features in child themes.
/********** Screen Reader Text starts about line 482 ************/
th {
font-weight: 400;
}
/* ## Screen Reader Text
--------------------------------------------- */
.screen-reader-text,
@ChrisCree
ChrisCree / Usage.txt
Created October 21, 2015 18:17
Genesis 2.2+ custom archive page template for customizing sitemap output. Copy the page_archive.php file, edit it as desired per the Usage.txt instructions below, and FTP it up to your Genesis child theme directory. Then create a page using the Archive page template to display your results.
The functions can be modified as needed using parameters from the WordPress Codex.
For example, to exclude specific pages line 30 above would be changed to this instead:
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'title_li=&echo=0&exclude=174,180' ) );
Where 174 & 180 are the page ID's of the pages to be omitted.
Here are the respective Codex pages for each function to find what parameters can be used:
wp_list_pages()
https://codex.wordpress.org/Function_Reference/wp_list_pages
@ChrisCree
ChrisCree / search_posts_only.php
Last active September 30, 2015 21:39
How to only return blog posts for the default WordPress search function.
<?php
// Don't copy opening PHP tag above
// Add below code to your theme's functions.php file.
// Only show blog posts in search results
add_filter( 'pre_get_posts','wsm_post_only_search_filter' );
function wsm_post_only_search_filter( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', 'post' );
}
@ChrisCree
ChrisCree / functions.php
Last active September 13, 2015 02:47
Change out logo images in the Genesis theme framework depending on which language is selected via WPML.
<?php
// Don't copy above opening PHP tag
// Display Custom logo based on WPML language displayed
add_action('wp_head','wsm_lang_logo_image_logic');
function wsm_lang_logo_image_logic() {
if ( !defined( 'ICL_LANGUAGE_CODE' ) ) {
return;
}
@ChrisCree
ChrisCree / functions.php
Created March 10, 2015 19:06
Change WooCommerce $0 zero price output from Free! to something else.
<?php
// Do not copy the opening <?php tag above
// Customize the Free! price output
add_filter( 'woocommerce_variable_free_price_html','wsm_custom_free_price' );
add_filter( 'woocommerce_free_price_html', 'wsm_custom_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'wsm_custom_free_price' );
function wsm_custom_free_price( $price ) {
// Edit content between single quotes below to desired output
return 'Prepaid Inventory';
@ChrisCree
ChrisCree / gf-setngs_functions.php
Created March 4, 2015 19:34
Filter to enable the setting in Gravity Forms where users can hide the field labels. This is useful in conjunction with the new Gravity Forms placeholder functionality as of version 1.9+
<?php
// DO not copy opening PHP tag above
// Enable Gravity Forms setting to hide form labels
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
@ChrisCree
ChrisCree / functions.php
Created December 5, 2014 14:09
Function for customizing the Genesis post info function based on date post was published. For example the below function shows different post info for posts more than 6 months old. Adjust as required.
<?php
// Don't copy opening PHP tag above
// Customize the post info function by date
add_filter( 'genesis_post_info', 'wsm_post_info_filter' );
function wsm_post_info_filter( $post_info ) {
$post_date = the_date( 'Y-m-d','','', false );
$date_limit = date( "Y-m-d", mktime(0,0,0,date("m")-6, date("d"), date("Y")) );
@ChrisCree
ChrisCree / androidmenu-functions.php
Last active December 14, 2015 18:15
Fix for Android devices, Genesis themes and dropdown menus.
<?php
// Do not copy opening PHP tag above
// Fix for Android devices not showing drop down menus when top level menu item clicked
add_filter( 'genesis_superfish_enabled', '__return_true' );
add_action( 'wp_enqueue_scripts', 'wsm_android_hover_fix' );
function wsm_android_hover_fix() {
wp_enqueue_script( 'hoverIntent' );
}