Skip to content

Instantly share code, notes, and snippets.

@10h30
10h30 / functions.php
Created March 21, 2017 13:36 — forked from srikat/functions.php
Primary Nav on left, Site Title or Logo in the middle and Secondary Nav on right in Genesis. http://sridharkatakam.com/primary-nav-left-site-title-logo-middle-secondary-nav-right-genesis/
//* Remove the default header
remove_action( 'genesis_header', 'genesis_do_header' );
//* Add Primary Nav in custom header
add_action( 'genesis_header', 'genesis_do_nav' );
//* Add Site Title in custom header
add_action( 'genesis_header', 'sk_do_header' );
function sk_do_header() {
@10h30
10h30 / functions.php
Created February 4, 2017 14:01
Quận / Huyện Việt Nam for Woocommerce
add_filter('wc_city_select_cities', 'my_cities');
/**
* Replace XX with the country code. Instead of YYY, ZZZ use actual state codes.
*/
function my_cities($cities)
{
$cities['VN'] = array(
'AN-GIANG' => array(
'Huyện An Phú',
@10h30
10h30 / gist:cd3dc3ee6ffa6b62215f8d4cbf90fd4f
Created October 12, 2016 14:02 — forked from amdrew/gist:c149510eef862f822b1f
AffiliateWP + WooCommerce - Alter the product commission depending on which category it's assigned to
<?php
/**
* Change the commission amount if products belong to certain categories
*
*/
function affwp_custom_wc_commission_per_category( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// You can specify an array of categories to alter the commission for. Separate by a comma and use either the term name, term_id, or slug
$categories = array( 'category-one', 5 );
@10h30
10h30 / for-functions.php
Created June 29, 2016 06:41 — forked from carasmo/for-functions.php
Ouput shortcodes on the 2.3.0 TinyMCE Genesis Archive Intro Text
<?php
// don't add above. This goes inside your child theme functions.php file
/** ======================================================================================
*
* Add shortcode to the Genesis 2.3.0
* Archive Intro Text Output
*
======================================================================================= */
add_filter( 'genesis_term_intro_text_output', 'do_shortcode' );
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attachment ){
// Get post parent
$parent = get_post_field( 'post_parent', $attachment);
// Get post type to check if it's product
$type = get_post_field( 'post_type', $parent);
if( $type != 'product' ){
return $attr;
@10h30
10h30 / acf_currency.php
Last active September 5, 2015 15:09 — forked from mattradford/acf_currency.php
ACF number field as formatted currency amount
<?php if(get_field('current_donations_total','options')) :
echo '&pound;' . number_format((get_field('current_donations_total','options')), 0, '.', ',');
endif; ?>
@10h30
10h30 / functions.php
Last active August 29, 2015 14:27
Modify Genesis Post Author shortcode to display outside the loop
add_filter ( 'genesis_post_author_posts_link_shortcode', 'filter_post_author_posts_link_shortcode', 10, 2);
function filter_post_author_posts_link_shortcode( $output, $atts ) {
global $post;
$id = ($post && property_exists($post,'post_author') && isset($post->post_author)) ? $post->post_author : 0;
$author = get_the_author_meta( 'display_name', $id);
$url = get_author_posts_url( $id );
$output = sprintf( '<span %s>', genesis_attr( 'entry-author' ) );
$output .= $atts['before'];
@10h30
10h30 / functions.php
Created July 17, 2015 03:57 — forked from srikat/functions.php
Excluding categories when using Display Posts Shortcode. http://sridharkatakam.com/exclude-categories-using-display-posts-shortcode/
//* Display Posts Shortcode - Exclude Categories
add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_categories', 10, 2 );
function be_display_posts_shortcode_exclude_categories( $args, $atts ) {
if( isset( $atts['cat_not_in'] ) ) {
$categories = explode( ',', $atts['cat_not_in'] );
$args['category__not_in'] = $categories;
}
@10h30
10h30 / gist:33cb766b58001e6c6bca
Created July 10, 2015 10:42 — forked from tomfinitely/gist:d865d05937d60e47ddb7
Genesis Sandbox Featured Content (GSFC) Widget Subtitles Function
add_action ( 'gsfc_post_content','add_subtitle', 10);
function add_subtitle(){
if ( function_exists( 'the_subtitle' ) ) {
the_subtitle( '<p class="entry-subtitle">', '</p>' );
}
}
jQuery(document).ready(function($) {
$(".featured-single").backstretch([BackStretchImg.src],{duration:3000,fade:750});
});