WooCommerce Custom Taxonomies

Recently I was asked to help out a local shop to develop a new WordPress site with WooCommerce. This is normally a super simple, straightforward task, but this one had a catch (don’t they always?).

Background

The customer had a requirement for “Team Stores” wherein they make custom products for Teams (ie local high school) where teams have products that are not displayed in the regular shop. This means they need to be able to add teams, show a list of all teams with logos, and then have shops that only display team products.

Approach – WooCommerce Extension

To approach this requirement I decided to develop a WooCommerce Extension plugin for a few reasons but mainly so that the “Product Teams” features would be portable to any theme that the client chooses now and also in the future, ie the client won’t be locked into one highly custom theme that has their business logic in it. It’s always much better to separate business logic from display wherever possible and this is no exception.

Intro WooCommerce Product Teams

The plugin solution involves several different pieces including a new ‘teams’ taxonomy for WooCommerce Products’ custom post type, custom taxonomy meta for the new teams taxonomy to support Team Logos, and overriding the default products query to filter out team products. The most interesting part of this plugin is registering a new taxonomy for WooCommerce Products and then overriding the product’s query without editing a theme, let’s see how these can be done.

Register a New Taxonomy

The first thing we’ll need to do is register a new taxonomy for the product Teams.

Excluding Team Products from the Shop

The next semi-challenging thing I needed to do was filter out the “Team Products” from the regular shop without editing the WooCommerce template files or adding any new templates to the theme. To do this, the pre_get_posts action perfectly fits the task to help us override the products query. Note – pre_get_posts overrides all queries on the frontend and backend, so you’ll need to be careful and use some logic on when and where you use this. 

Here is the full function that allows us to override the query only on the frontend and also only on the shop index, category and tag archive pages.

The Result

The end result is that I was able to register the teams taxonomy and control how they are displayed on the frontend in a theme agnostic manner. Here is a link to the full plugin on github – WooCommerce Product Teams. Enjoy!

New Plugin – Simple Post Alerts

I just released my 2nd WordPress plugin to on wordpress.org – Simple Post Alerts. The plugin is simple, it allows users to subscribe to alerts for new posts pending review and/or published.

A Little Background

When it comes to WordPress plugins, they are best done in the most simple form with little to no settings screens. I have been hunting around for a plugin that does notifications for posts “Pending Review” but everything I found was overloaded with settings, options, and lots of things that just really aren’t necessary. It’s much better to to keep things simple, lean, and do it well. I was also looking for something that would be easy for users to understand, ie the settings would be per user and on their profile settings and not hidden deep in a plugin administration page.

Intro Simple Post Alerts

Simple Post Alerts allows users to easily get alerts for new posts pending review and published.

screenshot-1
Post Notifications in the User Profile Settings

How does it work?

It adds permissions appropriate settings on the user profile for post notifications. For example, Editors (and above) who work with contributors can get notified of new posts that are “Pending Review” so they can know when they need to review and publish a post. Any site user can also get notified of new published posts so they can stay up to date. The notifications aren’t fancy, just a quick note with the title and a link, but that’s the point right?

The plugin is also super simple and hopefully straight forward to make it easy to fork and change to your specific use case. With some small modifications you could use it as the base for custom post types or custom post statuses. See the plugin on Github – Simple Post Alerts on Github.

Hopefully this plugin is just what you were looking for too, enjoy!

Twenty Thirteen Theme Preview

Here is a glimpse of Twenty Thirteen which will undoubtedly be released with WordPress 3.6.

One thing you’ll notice is that each post format has its own color, so each is distinct, yet they are all complimentary. The bold colors encourage authors to try out all the different formats and really show off their style. This color extends the full width of the window, which breaks your blog up into a lush, segmented timeline. This effect is even more pronounced on mobile browsers, where the screen can be dominated by one or two posts at a time, in all of their chromatic fullness.

Twenty Thirteen really prefers a single column layout. Widgets live best in the footer, where jQuery bricks them together (but it supports a sidebar, if you really insist). Header images have a fixed width and height, and will be cropped at smaller resolutions, so the best choice is an artistic header where not 100% needs to be shown all the time (it ships with three).

Can’t wait to get my hands on this theme and give it a try.

2013-02-19_08-37-24

 

 

Why I moved to WP Engine

I spent quite a bit of time optimizing my blog for fast page loads. More time that I want to admit and more time than it should take to get a relatively basic site like mine to load quickly. I stopped fumbling around and trying to figure this out on my Dreamhost account and move my blog to WP Engine.

Why WP Engine?

  1. Speed – They know how to configure servers for WordPress sites and they can achieve speeds that other hosting providers can’t provide. After migrating a couple of other sites to WP Engine, I’ve noticed a dramatic reduction in page load times. (see below)
  2. Security – WP Engine automatically scans and repairs hacking attempts  to ensure your site doesn’t get hacked in the first place, and then they continually monitor your site for hacks. If it still gets hacked, they’ll fix it for free!
  3. Commitment to WordPress – Perhaps most important, the primary reason they are so great is their commitment to the WordPress community.
  4. Automatic backups – WP Engine provides stupid simple backup and restore options — at no extra charge =  Peace of mind.
  5. Automatic WordPress updates – they automatically install WordPress security and maintenance upgrades, I’m always up to date. 🙂

Just How Fast is WP Engine?

Here is a snapshot of my site’s response time over a 6 month period going from standard Dreamhost, Dreamhost with WP Supercache, standard Dreamhost, and then the move over to WPEngine. The best response time I was able to achieve on Dreamhost was 635ms vs the best response time on WP Engine has been 303ms.
Dreamhost vs WP Engine