I have been using Pods for quite some time now and I cannot imagine creating a personal site or a private theme without it! I have decided to document all that I do with it, so that I and perhaps others can gain from it and always have it at their disposal.
What started out as a small post has grown! So I split it up into parts.
This post quickly discusses post types, taxonomies and custom fields. For a deeper understanding, you should google them, because Pods is a plugin that can manipulate these things and you first need a solid understanding of them.
A Quick Overview
A post type is basically a way of creating another section on your site. WordPress comes with two by default: post, and pages.
The ‘post’ post type is for your blog and any post made gets added in some order to your main blog page. You can help further organize these posts by adding categories and tags. These are known as taxonomies. People can click these taxonomies (categories and tags) and it will filter for posts that only have those categories.
Furthermore, what if you had, say, a recipe blog, and you wanted to add some extra meta data for ‘cook time’ and ‘prep time’ etc…
Adding this info to the content like it’s another paragraph might make it harder to grab later or to output it elsewhere like in the sidebar. So to make this content separate, we use a custom field, which is an arbitrary piece of data attached to the post. Below I have created a basic post. At the bottom, you can see I added a custom field of ‘cook time’.
The problem is, this is the post type ‘post’ and my categories, as you can see, have nothing to do with recipes. I don’t want my recipe to appear on my blog, I want a separate section for the food!
So by creating your own post type called ‘recipes’ you can add a new section to your site that will be separate from your blog or main articles. Then I can add a new taxonomy for it like ‘dish’ or something similar. This gives me a new section for different type of content on my site!
Creating a new post type, adding a taxonomy to it, and creating custom fields for it is time-consuming and involves a lot of code. Pods makes this simple by creating a backend interface where you can create new post types in minutes and give them a lot of configuration!
So let’s get to it! After installing the plugin Pods, go to Pods>Add New.
Here you will be asked if you want to extend or create a new post type. Extending will add Pods to already made post types (like ‘post’ or ‘pages’ or any other one made from a plugin you installed). Extending is limited in functionality. For now lets create a new one!
Lets pretend we are now making a new post type for a portfolio. A post type in Pods, it seems, is called a Pod. And a post in that Pod is a Pod item. So let’s make a new Pod! (images below can help)
Singular label: this would be Portfolio
Plural label: this would be Portfolios
Advanced+: This is where you can set a handle for the Pod so you can access it in your theme files. If you don’t set this, the handle would be ‘portfolio’. I prefer to add a prefix like ‘theme_name_protfolio’. I recommend doing this because it will keep you from having conflicts with a plugin or something else that might try to use ‘portfolio’. So mine is ‘snp_portfolio’.
Once you have pressed ‘Next’, its time to add some cool features! The first thing I do is click the tab for “Advanced Options”. Here I can set a lot of stuff that are self-explanatory. The question marks all about can help. Whatever is checked I usually leave checked. I add some stuff though:
For our portfolio, I would make sure to check ‘Enable Archive’ which will give me a page like ‘example.com/portfolio’, where all my portfolio posts will be listed. Unfortunately because I used a prefixed handle, the url would be ‘example.com/theme_name_portfolio’. So I need to add ‘portfolio’ as the slug override in the field that appears below it. I check whatever else I want to be checked.
Note, you can come back here at any time to add a taxonomy that you perhaps created, as you can see it offers me the built-in taxonomies already.
Save the pod, and you will discover a new menu item called Portfolio!
Here you can create a post like you normally would. You can view it and it may look like a regular post.
To make this new section truly unique, you would need to make special template files just for the portfolio section. You will need to make an arhcive-post-type-name.php and then a single-post-type-name.php and style them up in css! So my theme has a archive-snp_portfolio.php, where I show my portfolio as well as a single-snp_portfolio.php.
Well that’s how you start using Pods! Next we’ll begin making custom fields with it!