Archive | Snippets

RSS feed for this section

How to Hook Into WooCommerce to Trigger Something After an Order is Placed

14 March

It could be anything, but if you’re offering a service of some kind, rather than a simple downloadable product, you may need to trigger something to happen when an order is complete. Here’s a simple snippet illustrating how you can add an action to woocommerce_payment_complete. Add something like the following to your functions.php. You’ll need […]

Remove page numbers from wp_head for post type archives with WordPress SEO

11 March

If you’ve got WordPress SEO enabled this can be a tricky one. Took a while to track down exactly where those /page/2s were being added to my custom post type archive. I removed get_pagenum_link and start_post_rel_link and finally figured out the culprit was WordPress SEO! Just add something like the following to your functions.php // […]

No Nonsense WordPress Logout Link Without a Plugin

07 March

Add this WordPress Logout Link snippet and any logged in user can just go to /logout/ and they will be logged out: // WordPress Logout Link function wpbase_logout_redirect() { $path = $_SERVER[‘REQUEST_URI’]; if ( !is_user_logged_in() ) { return; } // Allow Logged in Users to Log out from /logout/ if (preg_match(“~/logout~”, $path) or is_page(‘logout’)) { […]

Where is the MySQL Dump File in BackupBuddy Full Backup?

06 March

When you download your BackupBuddy backup to your local machine it’s not immediately obvious where the MySQL database dump is located. To find it, extract the ZIP file and look for the following folder : wp-content/uploads/backupbuddy_temp/MYSERIALCODE. The MYSERIALCODE part will match the backup name serial code. Hope that’s helpful!

How To Get Rid of the Admin Notice Install the WooThemes Updater plugin to get updates for your WooThemes plugins

03 March

If you’re running WooCommerce plugin extensions 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’);

Add Twitter Bootstrap Icons to Widget Titles in WordPress

01 March

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’, ‘wpbase_iconthlist’); function wpbase_iconthlist() { return ‘<i class=”icon-th-list”></i>’; }

Enable Author Archives for Customers in WooCommerce

26 February

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’);