What Are Custom Post Types

Get A No Obligation Quote

Do You Need Help With Your WordPress Site?

Click through to the next page and complete the form to get a free no obligation quote to fix any issue you are having with your WordPress site.

Date

what are custom post types
You may have heard of a custom post types for WordPress and wonder what they are all about (or is…

You may have heard of a custom post types for WordPress and wonder what they are all about (or is that just me, I sometimes forget the real people who live outside tech-land sometimes don’t think in geek), but what are custom post types.

In this post I’ll give you a run down about custom post types and how they can help you.

What Are Custom Post Types

You can extend the way data is saved in your WordPress database by adding custom post types.  Instead of the standard post or page layouts, you can extend the database and store data in a way that is more meaningful to you and your requirement.

An example is probably required here.  Imagine you want to extend your site and have custom posts types of events.  An event has a title, details, location and a date.  This is a little different from a standard post, so we need a custom post type.

Lets Step through this example and talk about how this events custom post.

How To Create Custom Post Types

There are a number of ways you can create custom post types:

Code them up in your theme – you can write a function for your themes function.php file which creates a new custom post type.

Write a plugin – you can write a custom plugin which creates your custom post type and loads them up when the plugin is activated.

Plugins – there are plugins out there there that allow you to create your own custom post types.  They allow you to create CPT without the need to understand the coding required.  My favourite is this GUI custom post type creator.

http://wordpress.org/extend/plugins/custom-post-type-ui/

All of these approaches do the same thing.  Some code will be created and this will  run when you site loads, new posts types are created and a menu item added to allow you to add content.

They use the register post type function, here are full details if this your thing.

http://codex.wordpress.org/Function_Reference/register_post_type

Adding Custom Post Type Data

Once your code has been added, there will be a menu option to add, edit and amend your custom post type data.

You will get a version of the post editor that allows you to add your content.  It is the same editor we use for posts and page so there is not learning curve to add custom content.

Displaying Custom Post Type Data

Depending upon how your current theme is coded, your existing archive templates will display custom post types, but if you want something specific you will need to code up a template or add a custom query to existing pages templates.

For example if you want to show custom post types on your home page rather than blog posts, you would need a custom query loop.

If you don’t have the coding skills to write your own custom templates, Loop Buddy may be of help.

Re-Using Existing Post Functionality

We can re-use existing post functionality in our custom post types, for example if you want comments on your data, you can re-use that functionality.  This is setup when you create your custom post type.

Extending Post Data With Custom Fields and Meta Boxes

You can also add new data types of your custom post types and have meta boxes.  Here is an example from a plugin I use called In Post Ads which has some custom meta boxes.

Click to see full sized image
Click to see full sized image

As you can see a custom meta box has been added which gives us a series of check boxes.

It’s Not For The Feint Hearted

As you can no doubt guess adding custom post types requires a certain level of technical skill to code up theme files, plugins or to create templates to display content.

Some Examples I Have Built

The way you can use custom post types is limited only by your imagination.  Here are some of the projects I have worked on:

  • Events – the event has custom coding to have an event date and sort on that date, as opposed to the published date which will not show future events
  • Guides – I wrote a custom plugin to add and manage downloadable PDF guides
  • Bibliography – I wrote custom code to modify a bibliography for scientific journals and publications.  This has lots of custom meta for citations and references.

Wrap Up – What Are Custom Post Types

Custom post types move WordPress away from being just a blogging platform to being a fully functional content management system.

I don’t want to throw too much at you in one post, but next up I’ll talk about custom taxonomies.  You can create custom ways to organise your custom post types.

If you need help adding a custom post type config to your site jump over to my WordPress technical support page and I’ll give you a no obligation quote.

What are custom post types,  well this is an SEO excise to improve keyword density.

Photo Credit: L. Marie via Compfight cc

3 thoughts on “What Are Custom Post Types”

  1. Although I don’t think I would try this myself, it’s great info to have. I would contact you, since I had such great results last time. Thanks for the post!

  2. Holy smokes!

    I was just finishing putting an “event” on a friends WP website and thinking “there has to be a better way.” And just like that this arrived in my Email. Neil, you are scary psychic! Thanks!!

Comments are closed.

Get A No Obligation Quote

Do You Need Help With Your WordPress Site?

Click through to the next page and complete the form to get a free no obligation quote to fix any issue you are having with your WordPress site.

More
articles