Skip to content

Instantly share code, notes, and snippets.

View ChrisCree's full-sized avatar

Chris Cree ChrisCree

View GitHub Profile
@ChrisCree
ChrisCree / agentPress-listing-nav-functions.php
Last active June 9, 2021 15:09
Add Previous/Next navigation links to individual AgentPress Listings in the Genesis theme framework.
<?php
// Do not copy opening PHP tag above
// Add this code to your theme's functions.php file
// Add Previous/Next navigation to single listings
add_action( 'genesis_loop', 'wsm_add_listings_navigation' );
function wsm_add_listings_navigation() {
// bail if we aren't on a single listing CPT
if ( ! is_singular( 'listing' ) ) {
@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 / functions.php
Last active April 18, 2020 20:51
Adding a custom.css stylesheet to your Genesis child theme (will work for non Genesis themes as well). First create a custom.css file with your custom styles and FTP it up to your child theme directory. Then add the below code to your child theme's functions.php file.
<?php
// Do not copy opening php tag above
add_action( 'wp_enqueue_scripts', 'wsm_custom_stylesheet', 20 );
function wsm_custom_stylesheet() {
wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom.css' );
}

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 / gist:5888660
Last active March 15, 2018 22:55
Genesis doesn't put a page title on the blog page template by default. Here's a a function that will do that for you. Just drop it into your functions.php file.
<?php
// Don't copy the opening <?php tag above
// Add page title to blog page template
add_action( 'genesis_before', 'wsm_blog_page_title' );
function wsm_blog_page_title() {
if ( is_page_template( 'page_blog.php' ) ) {
add_action( 'genesis_before_content', 'wsm_show_blog_page_title_text', 2 );
}
}
@ChrisCree
ChrisCree / comment-form.php
Created July 15, 2014 21:57
Remove comments from specific category posts in the Genesis theme framework.
<?php
// Do not copy opening PHP tag above
// Remove comments from specific categories. Change out categories in array as needed.
add_action( 'wp_enqueue_scripts', 'wsm_remove_comments_in_category' );
function wsm_remove_comments_in_category() {
if ( in_category( array( 'No Comments', 'Uncategorized', ) ) ) {
remove_action( 'genesis_after_post', 'genesis_get_comments_template' );
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
@ChrisCree
ChrisCree / WooSalesPrice_functions.php
Created April 9, 2014 05:15
Function to show original non-sale price in WooCommerce cart.
<?php
// Do not copy opening PHP tag
// Show non sale product price in cart
add_filter( 'woocommerce_cart_item_price', 'wsm_show_nonsale_price', 10, 2 );
function wsm_show_nonsale_price( $newprice, $product ) {
$_product = $product['data'];
$saleprice = $_product->sale_price;
if ( $saleprice > 0 ) {
$newprice = '';
@ChrisCree
ChrisCree / functions.php
Last active October 19, 2017 20:26
Force IE not to use so-called "compatibility" mode in the Genesis theme framework.
<?php
// Do not copy opening php tag
// Force Stupid IE to NOT use compatibility mode
add_filter( 'wp_headers', 'wsm_keep_ie_modern' );
function wsm_keep_ie_modern( $headers ) {
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
$headers['X-UA-Compatible'] = 'IE=edge,chrome=1';
}
return $headers;
@ChrisCree
ChrisCree / clear_form_fields.js
Last active May 4, 2017 03:31
Customizing the Genesis HTML5 Comment areas to put labels inside entry fields and have them automatically clear when curser selects the fields.
jQuery(document).ready(function() {
jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}