Archive | Snippets

RSS feed for this section

Enable Shortcodes in Excerpts and Text Widgets

04 April

Just add the following to your functions.php: add_filter(‘the_excerpt’, ‘do_shortcode’); add_filter(‘widget_text’, ‘do_shortcode’); Twitter Facebook Google+ LinkedIn

Customize the WooCommerce Breadcrumb HTML Markup

03 April

The easiest way to do this is to override the woocommerce_breadcrumb function. Add something like the following to your functions.php (obviously add whatever changes you want to make to the markup in the appropriate places): // Customize the WooCommerce breadcrumb if ( ! function_exists( ‘woocommerce_breadcrumb’ ) ) { function woocommerce_breadcrumb( $args = array() ) { […]

How to Change the Placeholder Image in WooCommerce Within functions.php file

02 April

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

Comments Off on How to Change the Placeholder Image in WooCommerce Within functions.php file Continue Reading →

How to Customize the WooCommerce Add to Cart Message

30 March

Here’s a fun one. Let’s say you want to rename Cart to something else, like Bag or Briefcase. It can be tricky to find all of the places to make that change. You can, of course, edit the templates within WooCommerce, or even copy the templates into your theme to avoid crushing your changes when […]

How to Get Rid of the Pesky WooCommerce Catalog Ordering Dropdown

29 March

This one bugged me on one site I was building, but the solution is pretty simple. Just add the following snippet to your functions.php: // Remove WooCommerce Catalog Ordering Dropdown remove_action( ‘woocommerce_pagination’, ‘woocommerce_catalog_ordering’, 20); Twitter Facebook Google+ LinkedIn

Comments Off on How to Get Rid of the Pesky WooCommerce Catalog Ordering Dropdown Continue Reading →

How to Remove the WooCommerce Generator

28 March

On many of the sites I build, customers want clean HTML and as close to obfuscation for the platform as possible. That inevitably means removing various plugin generators. One in particular that’s tricky is WooCommerce due to the way it’s added with the global $woocommerce variable. To accomplish this feat, add the following to your […]

Remove / Dequeue Affiliates Pro Default Stylesheets

27 March

Here’s a simple function and hook combo you can add to your functions.php to dequeue the Affiliates Pro default stylesheets. function remove_affiliates_stylesheets() { wp_dequeue_style(‘affiliates’); wp_deregister_style( ‘affiliates’ ); } add_action( ‘wp_print_styles’, ‘remove_affiliates_stylesheets’, 101 ); You may alternatively need to swap the wp_print_styles with wp_enqueue_scripts like so: add_action( ‘wp_enqueue_scripts’, ‘remove_affiliates_stylesheets’, 101 ); Twitter Facebook Google+ LinkedIn

Filesystem Data Loss Lessons Learned

26 March

Today I learned a big lesson, and in a way, I got off easy. I was SSHed into one of my development boxes on Amazon EC2. I am currently in the middle of building a few client sites and they are all staged on one box. Now, I use EBS-backed EC2 instances, which means I […]

WordPress Debugging

26 March

OK, a simple one to start this thing off. If you’re writing PHP and you need to debug something and print some output to your error logs, here’s a nice custom debugging function that’s easier than the default error_log function. Certainly makes my life a lot easier. if(!function_exists(‘_error_log’)){ function _error_log( $stuff ) { if( WP_DEBUG […]

Enforce Alphanumeric Usernames in WordPress Registration

25 March

To kick things off, here’s a neat trick I recently figured out. One of my clients needed to enforce alphanumeric usernames so that users couldn’t enter email addresses and such as valid usernames. Turns out there’s a nice filter validate_username which does the trick nicely. You may need to customize the regex expression but here’s […]