Creating a Custom Post Type could be a little complicated.
But there’s a few ways that you can try creating a custom post type with a little less pain. First of all, let’s have a look at what the basic requirements are:
- You’ll need to define the Custom Post Type somewhere that WordPress will know in order to show you the button and other links on your Dashboard toolbar.
- In addition, you’ll probably want some taxonomies (ie: categories) to assign to your Custom Post Type.
- You’ll probably want to have some custom fields in your Custom Post Type
(other than just the simple Title, Content, Featured Image etc).
- You’ll want to have an archive display (a list of posts with thumbnail image, title, excerpt etc) for your Custom Post Type.
- Then you’ll need a display for each individual post.
We’ll look at each of these topics one by one. But to put the whole job in perspective, this tutorial has the following goals:
- Create a Custom Post Type. We’ll be creating Testimonials.
- Create PHP files for post archives and individual testimonials.
- In the following tutorial I’ll show you how you can create a front-end user interface where people can add a testimonial via a form with customised fields and an image upload.
This would create the testimonial and save as a draft pending admin approval.
(You wouldn’t want testimonials to be posted without some kind of oversight, right?)
If we were to do this from the ground up, with nothing but PHP, HTML and CSS, we could. A purist would want to tailormake each component lovingly by hand, but me, I just want to get the job done as cleanly as possible with a minimum of effort.
As I always say to my students “I’m gonna teach you to be the laziest developers alive”. After their initial disbelief, I add “Because you’ll be creating tight, reusable and modular systems that’ll allow you more time for the beach, bar or biking, whatever floats your boat”.
In order to get to market quickly, we’re going to use a bunch of tools. Some of them are free, some paid. But trust me, they work and will save you a bunch of time. They’ll pay themselves off in the first job.
- To create the Custom Post Type, we’ll be using CPTUI (open source)
- To create the Custom Fields, we’ll use Advanced Custom Fields (open source)
- To create the user form, we’ll use Formidable Forms. Not necessary to complete this tutorial, but essential in the next one.(open source).
Hang on – did I say that you’d have to pay somewhere? Well actually I did – there are ‘Pro’ versions of each of these plugins, which add significant extra functionality to the base level plugins. But the only one that’s absolutely necessary for this process to work is the Formidable Forms Pro version (About $49 for a single license). I’ll be dealing with that in the follow-on tutorial.