Skip to content

Instantly share code, notes, and snippets.

@10h30
10h30 / functions.php
Last active May 20, 2019
Woocommerce DYMO Print - Print custom field of variation products
View functions.php
//Tested on ycb.vn
function filter_wc_dymo_product($output,$object,$product,$variation,$labelID) {
if($labelID=='product') {
if(!empty($variation)) {
$barcode = get_post_meta( $variation->get_id(), '_barcode', true );
} else {
$barcode = get_post_meta( $product->get_id(), '_barcode', true );
}
$output[0]['BARCODE'] = $barcode;
@10h30
10h30 / year-archive-template.php
Created Oct 16, 2018 — forked from bradonomics/year-archive-template.php
Genesis Page Template displaying posts by year. Inspired by Alex Sexton's blog archives: https://alexsexton.com/blog/archives/ and built using code modified from Joe Mar Aparecio: http://www.joemaraparecio.com/customizing-genesis-archive-template-display-posts-month/
View year-archive-template.php
<?php
/**
*
* Custom Blog Loop for Bradonomics.
*
* Template Name: Bradonomics Blog
*
*/
//* Remove standard post content output
@10h30
10h30 / functions.php
Created May 16, 2018 — forked from srikat/functions.php
Testimonials Carousel in WordPress using Testimonials by WooThemes, Display Posts Shortcode and Slick jQuery. http://sridharkatakam.com/testimonials-carousel-wordpress-using-testimonials-woothemes-display-posts-shortcode-slick-jquery/
View functions.php
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'enqueue_custom_scripts_styles' );
function enqueue_custom_scripts_styles() {
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'slick-styles', get_stylesheet_directory_uri() . '/css/slick.css' );
wp_enqueue_style( 'slick-theme-styles', get_stylesheet_directory_uri() . '/css/slick-theme.css' );
wp_enqueue_script( 'slick-js', get_stylesheet_directory_uri() . '/js/slick.min.js', array( 'jquery' ), '1.3.15', true );
@10h30
10h30 / functions.php
Created May 30, 2017 — forked from anonymous/functions.php
Change the number of products per row in WooCommerce
View functions.php
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
@10h30
10h30 / functions.php
Created Mar 21, 2017 — 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/
View functions.php
//* 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 Feb 4, 2017
Quận / Huyện Việt Nam for Woocommerce
View functions.php
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 Oct 12, 2016 — forked from amdrew/gist:c149510eef862f822b1f
AffiliateWP + WooCommerce - Alter the product commission depending on which category it's assigned to
View gist:cd3dc3ee6ffa6b62215f8d4cbf90fd4f
<?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 Jun 29, 2016 — forked from carasmo/for-functions.php
Ouput shortcodes on the 2.3.0 TinyMCE Genesis Archive Intro Text
View for-functions.php
<?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' );
View Woocommerce product image alt
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 Sep 5, 2015 — forked from mattradford/acf_currency.php
ACF number field as formatted currency amount
View acf_currency.php
<?php if(get_field('current_donations_total','options')) :
echo '&pound;' . number_format((get_field('current_donations_total','options')), 0, '.', ',');
endif; ?>