Want a discount to apply automatically when a customer adds certain products to the cart—without forcing them to remember a coupon code? This snippet auto-applies (and removes) a chosen coupon based on product IDs in the cart. It also avoids applying in the admin and supports AJAX cart updates. Instructions: Replace the coupon_code and product […]
Archive | Snippets
RSS feed for this sectionMy Personal Collection Of Tips, Tricks and WordPress Best Practices
Suppress Function _load_textdomain_just_in_time was called incorrectly Notice
You’re getting this PHP Notice, and it’s cluttering up your logs, and you’re not going to patch upstream WordPress plugins, which would be silly: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the someplugin domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. […]
Remove Connect your store to WooCommerce.com Notice
If you’re running WooCommerce and you don’t want to connect your store to WooCommerce.com, add the following to your functions.php // Remove Connect your store to WooCommerce.com Notice add_filter( ‘woocommerce_helper_suppress_admin_notices’, ‘__return_true’ ); Twitter Facebook Google+ LinkedIn
Enable Author Archives for Customers in WooCommerce
Add the following to snippet your theme’s functions.php file: /** * Revert WooCommerce “Disable author archives for customers.” ‘feature’ */ function remove_wc_disable_author_archives_for_customers() { remove_action( ‘template_redirect’, ‘wc_disable_author_archives_for_customers’, 10 ); } add_action( ‘after_setup_theme’, ‘remove_wc_disable_author_archives_for_customers’); Twitter Facebook Google+ LinkedIn
How to change the placeholder image for WooCommerce
Simple: // Add a custom placeholder image location add_filter( ‘woocommerce_placeholder_img_src’, ‘custom_placeholder_img_src’); function custom_placeholder_img_src () { return ‘/assets/placeholder.png’; } Twitter Facebook Google+ LinkedIn
Fix bbPress Search in Canvas Theme
If you’re having trouble with bbPress searching in the Canvas theme you can try the following technique to get it resolved. Download the file bbpress.php from https://gist.github.com/mattyza/1b01583441b11c8d04d0 Place the following code in your functions.php file: //https://gist.github.com/mattyza/f210cadb7f70188d513d add_filter( ‘template_include’, ‘woo_custom_maybe_load_bbpress_tpl’, 99 ); function woo_custom_maybe_load_bbpress_tpl ( $tpl ) { if ( function_exists( ‘is_bbpress’ ) && is_bbpress() ) […]
Add Twitter Bootstrap Icons to Widget Titles in WordPress
Best option I’ve found is via a shortcode. Open your functions.php in your favorite text editor and first enable shortcodes for widget titles: add_filter(‘widget_title’, ‘do_shortcode’); Then, add your shortcode with the icon: add_shortcode(‘iconthlist’, ‘sozot_iconthlist’); function sozot_iconthlist() { return ‘<i class=”icon-th-list”></i>’; } Twitter Facebook Google+ LinkedIn
Set up a service dashboard using 30suns.com
Note: Unfortunately, looks like this service is no longer available. In a recent client project I was asked to set up a status dashboard that the client’s customers could access to track service outages. It would have been easy enough to implement this as a simple page in WordPress but I figured I’d do a […]
Remove Inline CSS from Query Multiple Taxonomies
Add to functions.php: / Don’t show the inline css for wp-query-multiple-taxonomies remove_action(‘wp_head’, array(‘QMT_Hooks’, ‘wp_head’)); Twitter Facebook Google+ LinkedIn
How To Get Rid of the Admin Notice Install the WooThemes Updater plugin to get updates for your WooThemes plugins
If you’re running an older version of WooCommerce but aren’t and don’t want to use their updater, you can remove the notice Install the WooThemes Updater plugin to get updates for your WooThemes plugins that appears on every admin page by adding the following to your functions.php // Remove WooCommerce Updater remove_action(‘admin_notices’, ‘woothemes_updater_notice’); Twitter Facebook […]