Instantly share code, notes, and snippets.

View functions.php
/**
* 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;
}
View functions.php
/**
* 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;
}
View functions.php
/**
* 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
View functions.php
//WooCommerce Remove Sidebar
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
View functions.php
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;
}