During a call with a potential client this week, I realized his WordPress-based project was going to need a custom post type with a few custom taxonomies attached. While I have already worked on several projects with custom post types, amazingly enough, I haven’t had to work with custom taxonomies yet. So it was time for a little practice.
When I’m trying to figure out how to do something, I’ve always found it works best to try and build a real-world application. Otherwise, there’s the tendency to say “that’s good enough” and then quit.
I don’t know about you, but in our house we repeatedly have the following conversation;
Wife: What do you want for dinner tonight?
Me: I dunno. What do you want?
Wife: I dunno. What sounds good?
Me: I dunno. Whatever.
The solution, the Wheel-o-Meals plugin.
How it works and what it does
The plugin creates a new post type called ‘Meals’ with two taxonomies attached for sides and veggies. You add in a meal with the title being the main dish (Steak, for example) and then add sides and veggies in the same way you would add tags to a blog post.
Once you’ve added several meal options, create a page and add the [meals] shortcode. View the page in a browser and the plugin randomly selects one of the possible meals and then randomly selects one side dish and one veggie for each day of the week. Here’s an example:
Now all you have to do is go shopping.
As I mentioned initially, I built the plugin in order to learn something specific. The plugin is very limited in it’s functionality. For example, it pulls each meal randomly so it doesn’t limit the number of times a meal can be selected (be prepared to eat Steak 7 days in a row!) You are welcome to download the plugin and do whatever you want with it. I have no plans to expand on or support the plugin, but I hope you can at least make some use of it.