Skip to content

Instantly share code, notes, and snippets.

View ChrisCree's full-sized avatar

Chris Cree ChrisCree

View GitHub Profile
@ChrisCree
ChrisCree / phpinfo.php
Created September 20, 2014 22:29
To find out what your website's server properties are including what version of PHP is running download this file as phpinfo.php and then FTP it up to your root WordPress directory. Then you can access it by going to your site's http://domain.com/phpinfo.php Remember to delete the file after you have the information you need!!
<?php phpinfo(); ?>
@ChrisCree
ChrisCree / page_archive-pages-only.php
Created November 17, 2014 16:35
Here is a page template that can be used with the Genesis framework to display only pages with the same layout as the Genesis Archive page template.
<?php
/**
* Page template file to display an archive list of only pages
*
*/
//* Template Name: Archive Pages Only
//* Remove standard post content output
remove_action( 'genesis_post_content', 'genesis_do_post_content' );
@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 / 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 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 / 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 / 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' );
}
<?php
// Add for Taxonomies
function wsm_add_for_taxonomies( $display, $meta_box, $taxonomy ) {
if ( 'taxonomy' !== $meta_box['show_on']['key'] )
return $display;
// Get the post's ID so we can see if it has ancestors
if( isset( $_GET['post'] ) ) $post_id = $_GET['post'];
elseif( isset( $_POST['post_ID'] ) ) $post_id = $_POST['post_ID'];
@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' );
}
@ChrisCree
ChrisCree / gist:5677645
Created May 30, 2013 13:00
Customizing the Author Box Title with the Genesis theme framework.
<?php
// Modify the author box title
add_filter('genesis_author_box_title', 'child_author_box_title');
function child_author_box_title($title) {
$title = sprintf( '<h3>%s %s</h3>', __( 'About', 'genesis' ), get_the_author() ) );
return $title;
}