Skip to content

Instantly share code, notes, and snippets.

View blogjunkie's full-sized avatar

David Wang blogjunkie

View GitHub Profile
@blogjunkie
blogjunkie / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@blogjunkie
blogjunkie / functions.php
Created August 5, 2015 07:33
Make WooCommerce product archive obey shop page layout settings
/**
* Make WooCommerce product archive obey shop page layout settings
*/
add_filter( 'genesis_pre_get_option_site_layout', 'vh_do_shop_layout' );
function vh_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 / functions.php
Created August 5, 2015 07:33
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 / screen.js
Created August 28, 2015 09:02
Open external links in new window
/**
* Open all external links in a new window
*/
jQuery(document).ready(function($) {
$('a').not('[href*="mailto:"]').each(function () {
var isInternalLink = new RegExp('/' + window.location.host + '/');
if ( ! isInternalLink.test(this.href) ) {
$(this).attr('target', '_blank');
}
});
@blogjunkie
blogjunkie / style.css
Last active August 31, 2015 09:04
Better default styling for Related Posts for WP plugin. Replace the default CSS in the Settings → Related Posts → Styling tab.
.rp4wp-related-posts:after,
.rp4wp-related-posts ul:after {
clear: both;
content: "";
display: table;
}
.rp4wp-related-posts > ul {
margin-left: 0;
padding-left: 0;
@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 / 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' );