Skip to content

Instantly share code, notes, and snippets.

View blogjunkie's full-sized avatar

David Wang blogjunkie

View GitHub Profile
@blogjunkie
blogjunkie / functions.php
Created October 1, 2015 14:20
Adding support for WooCommerce in Genesis via Stéphane Bergeron. "I'm using a modified version of this: http://joshmallard.com/2013/09/23/woocommerce-genesis-2-0/ The way I modified it is that, I don't put anything in functions.php other than the add_theme_support( 'woocommerce' ); line. Instead I replace what Josh has in his woocommerce.php tem…
// Declare WooCommerce support for your theme
add_theme_support( 'woocommerce' );
@blogjunkie
blogjunkie / functions.php
Created December 7, 2015 14:23
The Shop page is actually an archive page for the Products CPT and won't obey the layout settings for the page. This snippet fixes that.
<?php
/**
* Make WooCommerce product archive obey shop page layout settings
*/
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_shop_layout' );
function child_do_shop_layout( $opt ) {
if ( is_post_type_archive('product') ) {
$opt = get_post_meta( wc_get_page_id('shop'), '_genesis_layout', true);
return $opt;
@blogjunkie
blogjunkie / taxonomies.php
Created February 26, 2013 02:25
Register custom taxonomies 1) quote topic and 2) quote author for quote custom post type
<?php
/**
* Taxonomies
*
* This file registers any custom taxonomies
*
* @package Core_Functionality
* @since 1.0.0
* @link https://github.com/billerickson/Core-Functionality
* @author Bill Erickson <bill@billerickson.net>
@blogjunkie
blogjunkie / gist:4712311
Last active April 2, 2016 05:57
Display a custom message for WooCommerce subscription products in order complete email. Goes in your theme's functions.php or as a plugin. Credits: Patrick Garman (@pmgarman)
<?php
/* Custom message for subscription products in order complete email */
add_action( 'woocommerce_email_after_order_table', 'wc_completed_email_snippet' );
function wc_completed_email_snippet( $order ) {
$order_statuses = array( 'completed' ); // order statuses to enable the email on
$display_cats = array( 148, 149 ); // cat ID's of products to display the message on completed emails for
if( in_array( $order->status, $order_statuses ) )
return; // only completed orders
if( !class_exists( 'WC_Subscriptions_Order' ) || !class_exists( 'WC_Subscriptions_Renewal_Order' ) )
@blogjunkie
blogjunkie / template-page-builder.php
Last active May 11, 2016 13:28
A custom page template for #GenesisWP to play nice with page builders by making the content area full width. Works great with the Beaver Builder http://clickwp.me/beaver
<?php
/**
* Template Name: Page Builder
*
* This page template only works with Genesis child themes and works great with the
* Beaver Builder plugin. Learn more: http://clickwp.com/blog/beaver-builder/
*/
// Force full width content layout to remove sidebar
@blogjunkie
blogjunkie / mobile.php
Created November 23, 2016 09:23 — forked from marco-s/mobile.php
Switch between two themes, depending on what domain is used to access a site
<?php
/*
* This solution assumes you've already set up your site so that the site domain is
* your "normal" (non-mobile) domain, and your theme is your non-mobile theme.
*
* In short, what it does it check to see if the site is being accessed through the
* mobile domain. If it is, the mobile theme is used instead of the normal theme, and
* all links point to the mobile domain (so navigatiion doesn't take visitors to the
* regular domain.
@blogjunkie
blogjunkie / functions.php
Last active December 23, 2016 10:52 — forked from srikat/functions.php
Custom Shortcode to display First Category in Genesis. https://sridharkatakam.com/custom-shortcode-to-display-first-category-in-genesis/
add_shortcode( 'post_category', 'sk_post_category_shortcode' );
/**
* Produces the first category link.
*
* Supported shortcode attributes are:
* after (output after link, default is empty string),
* before (output before link, default is 'Tagged With: '),
* sep (separator string between tags, default is ', ').
*
* Output passes through 'genesis_post_categories_shortcode' filter before returning.
@blogjunkie
blogjunkie / function.php
Last active August 30, 2017 13:04
Serve minified stylesheet when SCRIPT_DEBUG or WP_DEBUG is defined
<?php
/*
* Manage loading of theme styles
*/
add_action( 'after_setup_theme', 'child_load_stylesheet' );
function child_load_stylesheet() {
// First, remove the stylesheet
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
@blogjunkie
blogjunkie / remove-beaver-builder-from-admin-woocommerce.php
Created January 5, 2018 23:32 — forked from carasmo/remove-beaver-builder-from-admin-woocommerce.php
Remove Beaver Builder link and tab in Admin for WooCommerce pages
<?php
//* DON'T ADD ABOVE
/*
*
* READ ME:
* I'm using Beaver Builder for page post types and I don't want that option on
* WooCommerce store, cart, checkout, and my account pages. I don't want the client to ask why she can't change
@blogjunkie
blogjunkie / child-theme-settings.php
Last active May 27, 2018 13:45
Integrate the WordPress Media Uploader in Theme Options. Reference this function from your add_meta_box() callback
<?php
function upload_image_metabox() {
echo '<p><strong>Upload image</strong></p>';
echo '<input type="text" id="child_logo_url" name="' . $this->get_field_name( 'welcome-image' ) . '" value="' . esc_attr( $this->get_field_value( 'welcome-image' ) ) . '" size="50" />';
echo '<input id="child_upload_logo_button" type="button" class="button" value="Upload Image" /> ';
?>