Skip to content

Instantly share code, notes, and snippets.

View johnmccole's full-sized avatar
💭
I may be slow to respond.

John McCole johnmccole

💭
I may be slow to respond.
  • Glasgow, Scotland
View GitHub Profile
@johnmccole
johnmccole / wp-config.php
Last active February 15, 2018 16:59
Add the below snippet to wp-config.php to stop Contact Form 7 from auto-generating p tags.
define( 'WPCF7_AUTOP', false );
@johnmccole
johnmccole / map-type.js
Last active February 20, 2018 08:58
Change the arguement "mapTypeId" to 'google.maps.MapTypeId.HYBRID' to set the default map type to Satellite view, with labels included. Example included below:
// vars
var args = {
zoom : 16,
center : new google.maps.LatLng(0, 0),
mapTypeId : google.maps.MapTypeId.HYBRID
};
@johnmccole
johnmccole / multiselect.php
Last active February 23, 2018 09:36
An example of outputting all selected options of a multi-select field. Add to templates as required. Outputs a comma delimited list of selected options.
<?php $sectors = get_field('main_sectors'); ?>
<?php if ( $sectors ): ?>
<span><?php echo implode(', ', $sectors); ?></span>
<?php endif; ?>
@johnmccole
johnmccole / wp-config.php
Last active March 1, 2018 18:18
To remove ALL WooCommerce data on plugin deletion, add the below snippet to wp-config.php. WARNING: This will remove ALL data (products, orders, categories, etc), use at your own risk.
define('WC_REMOVE_ALL_DATA', true);
@johnmccole
johnmccole / remove-count-sort.php
Last active March 2, 2018 15:31
Remove the results counter and default from WooCommerce, just the add the below snippet to functions.php.
// Remove the sorting dropdown from Woocommerce
remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_catalog_ordering', 30 );
// Remove the result count from WooCommerce
remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_result_count', 20 );
@johnmccole
johnmccole / functions.php
Last active February 28, 2018 10:53
Add the below snippet to functions.php to output the associated tags with a product in the archive pages. Update as neccessary.
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_product_loop_tags', 5 );
function woocommerce_product_loop_tags() {
global $post, $product;
$tag_count = sizeof( get_the_terms( $post->ID, 'product_tag' ) );
echo $product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' );
}
@johnmccole
johnmccole / functions.php
Last active February 28, 2018 16:34
Add the below snipper to fucntions.php to remove the 'Readd More' button from the WooCommerce loop.
//* Remove WooCommerce Add to Cart/Read More button
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
@johnmccole
johnmccole / functions.php
Last active March 1, 2018 18:20
Remove WooCommerce's default breadcrumbs from a site.
// Remove default breadcrumbs
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
@johnmccole
johnmccole / functions.php
Last active March 1, 2018 15:13
Add the below snippet to functions.php to change the number of products per row, this example changes it to 3.
// 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
}
}
@johnmccole
johnmccole / wp-config.php
Last active March 6, 2018 16:23
Add the below snippet to wp-config.php to change the default uploads folder for WordPress, this is best done on a fresh install of WordPress before any media is uploaded.
define( 'UPLOADS', 'wp-content/files' );