Hello WP community members and happy October!
Here's the "WP Question of the Month" (okay, so technically it's three questions...lol):
Do you build custom content types?If so, do you do it manually or with a plugin?What do you use custom content types for?
I look forward to hearing your answers and advice for the group!
For those of you whose answer is, "HUH!?", I thought I'd very quickly summarize what a custom post type is. You may have them on your site and not even know it!
From Plethora of Posts: A User-Friendly Introduction to Custom Post Types:
You already know about Posts and Pages in WordPress, right? Guess what? Those are post types.
These standard post types are part of the default WordPress setup.
The article continues:
Custom post types are just like standard posts or pages, except for:
How do you know when you need to create a custom post type as opposed to use the standard post and pages built into WordPress? Well, a good rule of thumb is whether you have (or plan to have) a plethora of posts.
Let’s look at some everyday examples where a custom post type might come in handy:
So if you have "Events" or "Products" or "Services" or "Cats" (!) listed in your admin menu, those are probably custom post types!
Using CPTs is a great way to take your site to the next level and make it easier to manage in the long-term. I hope you all can share what custom post types you're using and how you set them up!
Do you build custom content types?
Yes, on most websites.
If so, do you do it manually or with a plugin?
These days I code it manually. But I used to use a plugin called CustomPress (bought from WPMU Dev).
What do you use custom content types for?
Every time, it wasn't just the Custom Post Type that was required, Custom Fields and Taxonomies were too.
A couple of examples of custom post types, taxonomies and custom fields:
1. Healthwatch Derbyshire
The hospitals and surgeries are a Custom Post Type called "Local Services". We needed a custom post type because these don't fit the model of a normal post or a page in WordPress.
The list of care homes, dentists etc is a Taxonomy. In other words, these are categories that are only apply to the custom post type.
The five star rating is a Custom Field. The phone numbers, addresses etc of each local service are also custom fields.
These are all created by code in a custom-built plugin that I coded specifically for local Healthwatch organizations.
2. Register of Professional Turners
The Custom Post Type is for individual woodturners.
The Taxonomy is the type of woodurning offered e.g. bowls and platters, or antique repairs.
The Custom Fields include their address, email, phone number and website address.
The plugin does this:
I've deliberately coded it all manually so that the plugin can be installed on any website and still work, without them needing other plugins active. However, if we install the Ajax Search Pro plugin then we get a much fancier search experience, as on healthwatchbucks.co.uk.
This took me a few months to build. An exhausting process. But worth it, because I'm now selling the plugin to other Healthwatch organisations. There are still some faults, for example a few places where the theme and plugin are too intertwined, but working on that.
Largely for my own curiosity, I compiled the names of custom post types from 13 of my sites (most of what I've done in the last 2 or 3 years). Hopefully the breadth gives people a good idea of what "CPTs" are good for. Listed roughly in order of frequency:
You can see how many of these might be used on a "common" nonprofit site.
As for resources, the coders in the room can't go wrong with Justin Tadlock's tutorial "Custom Post Types in WordPress." This may sound silly, but that tutorial is practically famous among coders because of how many people learned about CPTs from it. Highly recommended!
Interesting that Events tops your list, given that there are so many plugins and third party solutions already available to handle this. How come you do it that way?
Kittens, well obviously.
This is a great discussion.
I don't have much to add in terms of tutorials - and there's plenty of stuff out there if you Google.
I use the Custom Post Type UI plugin for prototyping new custom posts types, but then convert to code once I'm happy. This stops clients going "Oooh, what's this" and removing things that they shouldn't.
I've not gone to the effort of creating a list, but I've used them for lots of things similar to Mark. Of the top of my head and in no order in particular:
I'm sure there are lots more. I built one site that, behind a login, had a discussion interface a bit like a Facebook wall or simple forum that was a custom post type with comments.
Some of these things existed before you could put meta data on custom taxonomies, and I would probably implement them as taxonomies now.
Sites that have a prominent use of these things include:
1) Minority Rights (and the micro-site for their annual report: http://peoplesunderthreat.org/) - these have lots of information about countries and the indigenous minority populations that inhabit them. The directory in particular shows off how these are more than just taxonomies.
2) Speaking of directories, this really simple site for a local branch of our mental health charity Mind has a directory that made from a CPT and custom taxonomies: http://lambethandsouthwarkmind.org.uk/directory/ This is quite old now and one of the first things I built with CPT's.
3) I won't even start trying to explain the data modelling behind the vast Bretton Woods Project website, but see if you can spot what might be a CPT!
4) Here's an example of a "Resources" post type in action - with associated meta data, taxonomies and filtering: http://avaproject.org.uk/resources/
As a quite-technical aside, I'm a bit of a coder Geek, and it may be interesting to know that I like to "abstract" the functions that WordPress gives me on a per-post-type basis to make my code simpler and easier to look after. As an example, I may want to fetch a list of posts to populate a dropdown to select things from. With WordPress's functions and API's you might do something like this:
$things = new WP_Query([ 'post_type' => 'thing', 'posts_per_page' => -1, 'order_by' => 'title', 'order' => 'ASC']);
(or the get_posts() equivalent)
But I use a little library that helps me write things like:
$things = Thing::get_all();
$fancy_things = Thing::get_by_meta('fancy', 'yes');
The code that I use to do that is here: https://github.com/rosswintle/Oikos-Post-Types - there are other (sometimes better) ways of doing this.
The main thing is, if you're using lots of custom post types, you can really help yourself by organising your code well and not just having a single enormous functions.php
Hope that's helpful!
Thanks for the tip / trick for keeping functions file small. Will definitely implement it on the next large project.
To answer Jason's question, Event is a great example of how a plugin can register a custom post type for us and provide all the benefits without requiring any code. I always use The Events Calendar which creates an Events post type (along with Venues and Organizers as well).
Other plugins that I've had create custom post types for me include:
Great questions Cindy! Love this thread.
Do you build custom content types?
All the time. I think that's what makes WordPress so fantastic. If you can think it up, you can probably build it.
I almost exclusively build custom post types manually. But it's what I do for a living, so it makes sense to do. It gives me complete control over what I'm creating, and let's me sleep at night knowing that, if something breaks due to a WordPress update or whatever (I've seen this more than once) I can fix it and not have to wait for a plugin update to fix the issue.
If I worked for an org that didn't have a developer on staff, I'd have no issue using a plugin to create post types. But I would 100% definitely research the plugin to assure it has a good history and the likelihood it'll be supported in the future. But the beauty of WordPress is the vast amount of tools available to let content producers create beautiful things! So use the resources available, and do it after doing your due diligence on the tool you're going to use. Read the plugin reviews, see its history... When was the last time it was updated? Is it compatible with the latest WP version? And so on.
All that said... Even if you are going to manually create your custom post types, plugins to do this still have their role. They're great for quickly prototyping. I did this a few months ago for a project at NTEN. It was awesome to show folks an almost functional web app so they could decide if web dev was on the right track. When we decided it was, I used what I learned building the post type with the plugin, and just went ahead and recreated it manually, adding additional features that wouldn't have been possible otherwise. It was definitely worth the time investment.
Pretty much everything you see on nten.org is custom. The only thing that isn't, I believe, are pages.
I use Custom Post Types on just about every single website I create. I believe it strongly helps for ease of site management for the client which is what we really focus on for the non-profits we work with. We code them in manually since we try to limit the number of plugins we use.
Alliance Rally is one site where we used them for their conference sessions - these are custom post types with taxonomies to filter and custom fields to show the session details. The faculty page is also a custom post type.....
Now that I think about it - I cannot imagine a website where I would not use them, I am kind of obsessed with them!