Skip to content

Instantly share code, notes, and snippets.

:shipit:
Working from home

Mike Jolley mikejolley

:shipit:
Working from home
Block or report user

Report or block mikejolley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mikejolley
mikejolley / functions.php
Created May 10, 2016
WooCommerce - Remove product data tabs and hook content in sequence instead
View functions.php
<?php // Do not include this if already open!
/**
* Remove existing tabs from single product pages.
*/
function remove_woocommerce_product_tabs( $tabs ) {
unset( $tabs['description'] );
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );
return $tabs;
@mikejolley
mikejolley / functions.php
Created May 6, 2016
WooCommerce - Change number of displayed upsells on product pages
View functions.php
add_filter( 'woocommerce_upsell_display_args', 'custom_woocommerce_upsell_display_args' );
function custom_woocommerce_upsell_display_args( $args ) {
$args['posts_per_page'] = 5; // Change this number
$args['columns'] = 5; // This is the number shown per row.
return $args;
}
View gist:6955ebc7a0a24c49150d30067b83b4f2
function custom_job_post_type_link( $permalink, $post ) {
if ( $post->post_type !== 'job_listing' )
return $permalink;
$permalink .= '-' . $post->ID;
return $permalink;
}
add_filter( 'post_type_link', 'custom_job_post_type_link', 10, 2 );
@mikejolley
mikejolley / query.sql
Created Apr 26, 2016
WooCommerce - SQL to Delete users with no orders or posts
View query.sql
DELETE from wp_users where wp_users.ID not in (
SELECT meta_value FROM wp_postmeta WHERE meta_key = '_customer_user'
) AND wp_users.ID not in (
select distinct(post_author) from wp_posts
);
delete from wp_usermeta where wp_usermeta.user_id not in (select ID from wp_users);
@mikejolley
mikejolley / functions.php
Created Apr 14, 2016
WooCommerce - Disable ALL sale prices with code
View functions.php
<?php
/**
* After adding this code to theme functions.php, ensure you clear transients via WC > System Status > Tools
*/
add_filter( 'woocommerce_get_sale_price', '__return_empty_string' );
add_filter( 'woocommerce_variation_prices_sale_price', '__return_empty_string' );
add_filter( 'woocommerce_variation_prices_price', 'custom_get_price', 10, 2 );
add_filter( 'woocommerce_get_price', 'custom_get_price', 10, 2 );
@mikejolley
mikejolley / gist:674f1b57e8a1390a8fd8
Created Mar 23, 2016
WP Job Manager Geolocation - Set language
View gist:674f1b57e8a1390a8fd8
// Add to theme functions.php
add_filter( 'job_manager_geolocation_endpoint', 'change_geocode_lang' );
function change_geocode_lang( $endpoint ) {
// Use language from https://developers.google.com/maps/faq#using-google-maps-apis
return add_query_arg( 'language', 'en-GB', $endpoint );
}
View gist:fb32936bd5c6605bf2a3
add_filter( 'pre_option_job_manager_alerts_page_id', 'wpml_pre_option_job_manager_alerts_page_id' );
function wpml_pre_option_job_manager_alerts_page_id( $id ) {
return icl_object_id( $id, 'post', true );
}
@mikejolley
mikejolley / gist:d4c46102d69d4560abb6
Created Mar 21, 2016
WooCommerce - Allow non-admin access to backend, and enable admin_bar
View gist:d4c46102d69d4560abb6
/* Code goes in theme functions.php */
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
View gist:d1e0a267afeedd9232b7
add_filter( 'woocommerce_product_add_to_cart_url', 'custom_woocommerce_product_add_to_cart_url', 10, 2 );
function custom_woocommerce_product_add_to_cart_url( $url, $product ) {
if ( $product->is_type( 'simple' ) ) {
$url = get_permalink( $product->id );
}
return $url;
}
View gist:6ce453b113cf29edd883
// code added to theme functions.php file
add_action( 'woocommerce_after_shop_loop_item', 'show_product_excerpt' );
function show_product_excerpt() {
the_excerpt();
}
You can’t perform that action at this time.