Using Pods with WordPress
- July 22, 2020
- Leave a comment
‘Pods’ is a custom post type and custom fields plugin for WordPress. It is popular, free, and easy to use. It comes with several extensions to make your life easier.
Pods is such a versatile tool that provides granular control on every aspect of custom post types and fields to developers and non-developers alike. It allows easy auto-templating of custom post types, using shortcodes for normal users. While, for the developers, it provides full-on programming capabilities and REST API controls.
What are Pods?
Any custom post type or taxonomy created by the Pods plugin is called a Pod. You can access those pods using Pods API, which is similar to the default WordPress API. Using Pods API is optional, as you can reference the new custom post types and taxonomies using the default WordPress wp_query functions. However, if you have defined complex relationships between pods, and want to leverage the power of Pods plugin and pagination, you will need to use the Pods API.
In addition to creating new custom post types, taxonomies, or custom fields, you can also extend existing post types, categories, and even users. Moreover, you can create one-many and many-many relationships between any custom pod.
Now you may be familiar that any custom fields for a custom post type are stored in a meta field by default. In the case of thousands of posts, filtering by meta fields can have a huge impact on the website load speed, and if you have custom relationships through those meta fields, you can forget about any advanced queries. Pods come to your rescue here by allowing you to create a separate table for your pod. So, instead of saving custom fields in post meta, the pods create columns in the separate table. The good part is that it still allows normal WordPress queries to work.
Pods allow two templating modes:
1. Auto Templating
This is useful for non-programmers. Pods automatically create templates for the pods that you create. Pods allow you to add shortcodes to change the layout of the template. You don’t have to touch any file for the templating. Pods templates are designed in the interface provided by the plugin.
2. PHP Templates
Since Pods create custom post types and taxonomies, their templates can be easily created in the theme’s folder. This process is the same as any normal template for any custom post type that you would create. Pods provide a comprehensive API to reference any field, relationship, or taxonomy in the templates.
The complete documentation of the API exposed by Pods can be found on the following link:
Pods allow developers to access any part of the pod using its API. It allows add/update/delete methods. Moreover, it provides an ability to expose the REST API of the custom post type without a single line of code.
If you need support, the Pods support team is always there to provide support on their slack channel.
Let’s demonstrate the usage of Pods by example.
Suppose that we need to store the information of Physicians in WordPress. We will need to store their location and specialties.
We will create custom post types for Physicians and Locations. We will then create a custom taxonomy for Specialities. After that, we will create a relationship between 1) Physicians and Locations, and 2) Physicians and Specialities.
It is a 100% free plugin. You will need to download it from WordPress’s plugin repository.
Go admin dashboard
Find, install and activate
2.0 Create Physician custom post type
Click on Create new
2. Provide a label for the post type.
3. Create a custom field for telephone and save the field.
4. Enable auto templating and save the pod.
3.0 Create Location custom post type
1. Click on Create new
2. Provide a label for the post type.
3. Create a custom field for physicians, and allow multiple physicians per location. Then Save the Pod.
4.0 Add Location in Physician custom post type
1. Click on Edit Pods, and edit the Physician
2. Create a new relationship field for Location. We will leave it as a single select in Additional Field Options, and save the field.
5.0 Add Expertise taxonomy and attach to Physician
1. Click on Create new.
2. Select taxonomy and provide a label for the taxonomy.
3. In advanced options, scroll to the bottom of the page and associate the post type with Physicians. Save the pod.
6.0 The Result
Here is how the physician’s post type looks when you edit it.
7.0 Displaying Record on Frontend
To view all the content of the Physician’s CPT on the frontend. Edit the description and add shortcodes.
Now that you have witnessed that power of Pods, and have seen how you can create powerful content types without adding a single line of code, get started with implementing your custom solutions. In case you need more advanced stuff, like Pods based filters, data migrations, and advanced layouts, don’t forget to contact PressTigers! We have got it all covered!