Skip to content

Instantly share code, notes, and snippets.

@elvinlee
elvinlee / functions.php
Created August 21, 2015 08:41
Change the Order of Kiwi Logo Carousel
/**
* Default is ASC, change to DESC
**/
add_action( 'pre_get_posts', 'custom_kiwi_order' );
function custom_kiwi_order( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', 'kwlogos' );
$query->set( 'order' , 'desc' );
return $query;
}
@elvinlee
elvinlee / functions.php
Created July 29, 2015 09:27
WordPress: Add Post Type & Post Name to Body Class
/**
* Add Post Type & Post Name to Body Class
* For example: page-about-us
*/
add_filter('body_class', 'add_post_class');
function add_post_class($classes) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
@elvinlee
elvinlee / functions.php
Last active August 29, 2015 14:26
WC Vendors: Rename "Sold by" to Seller
/**
* Can change Seller to any name you want to change
*/
function rename_sold_by($text) {
$return = str_replace('Sold by', 'Seller', $text);
return $return;
}
add_filter('wcvendors_sold_by_in_loop', 'rename_sold_by'); // Product Loop
add_filter('wcvendors_cart_sold_by', 'rename_sold_by'); // Cart Page
add_filter('wcvendors_cart_sold_by_meta', 'rename_sold_by'); // Single Product Page
@elvinlee
elvinlee / functions.php
Last active January 19, 2016 13:59
WooCommerce: Remove Sidebar from all WooCommerce Page
//WooCommerce Remove Sidebar
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
@elvinlee
elvinlee / functions.php
Last active August 29, 2015 14:13
WooCommerce: Disable BACS if Customer Checkout Country Out of Singapore
add_filter( 'woocommerce_available_payment_gateways', 'bacs_disable_outside_singapore' );
//Disable bacs if the country not in Singapore
function bacs_disable_outside_singapore( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['bacs'] ) && $woocommerce->customer->get_country() <> 'SG' ) {
unset( $available_gateways['bacs'] );
}
return $available_gateways;
}