How to Create an Advanced Content Type
As well as the standard WordPress objects of Post Types, Taxonomies, and Fields, Pods lets you create Advanced Content Types. These Content Types are created in their own table in your database, meaning they have more flexibility than youget with standard Content Types. However, when you create them it means that you are reliant on Pods for using their functionality. Unless you are a developer with a specific need for Advanced Content Types, it’s very unlikely that you’ll need to use them. You can learn more in our guide to Advanced Content Types.
Here are three examples of occasions when Advanced Content Types might be used:
- You need your data to be separate from your WordPress database tables. This might be necessary, for example, if you are using another piece of software with which you wish to share the database. Advanced Content Types means that you can interface between WordPress and that software.
- You are querying many fields at once from the same table (typically, at least most than 15). This could be used for reporting and statistics.
- You have data that gets reset periodically.
Remember that in normal situations Custom Post Types are what you need. Advanced Content Types require advanced knowledge of database structures.
Sanity checked? If you’re sure you want to go ahead, this guide will walk you through creating an Advanced Content Type.
Create your Advanced Content Type
First you’ll need to enable the “Advanced Content Types” component under Pods Admin > Components (Advanced Content Types are not enabled by default)
Next, navigate to Pods Admin > Add New.
Click on the Create New button.
From the drop-down menu select Advanced Content Type.
Let’s use an example.
A library has a database for all of its books, but it also wants to display them in its WordPress website. The library software keeps track of books and records them as being available of checked out. WordPress displays this information. Pods is used to interface between the two.
Give your Content Type a Plural and a Singular Label. For this example, the plural is books and the singular is book.
Click on the advanced tab to change the identifier. This is how your Advanced Content Type will be referred to in the code and in shortcodes.
When you’re happy, click Next Step.
Add your Fields
Custom Fields let you associated data with your Advanced Content Type. Use our guide to learn more about Custom Fields.
You’ll see that some fields have already been created. You can use these if you wish, or you can remove them.
To add a field, click on the Add Field button.
There are three tabs:
- Advanced Field Options
Let’s take a look at each of them.
This tab has the basic information that is required to create your field. Your options are:
- Label: the field label that will appear in your user interface.
- Name: the name of the field that you will use in your code and shortcodes.
- Description: a description of the field. This could be an instruction for the user or just a description. It is not required.
- Field type: this is where you determine the type of field. There are a number of options including email, website, color picker, and even a Visual editor.
- Options – Required: if a field is required the user cannot save the post until it is completed.
- Options – Unique: a unique field must have a unique value inserted into it.
Below is an example of the form completed for an ISBN field for the Book Advanced Content Type:
Additional Field Options
The additional field options tab gives you options that are contextual to the field type you have selected. Let’s take a look at some examples.
For the plain number field that was selected in the above example, options are provided for format, decimals, and maximum length.
The currency field has options for currency sign, currency placement, format, decimals, and maximum length.
The WYSIWYG Visual Editor field has options for different editors, output options, allowed html tags, and maximum length
Whatever field you choose, it’s worth checking out the additional field options to see how you can customize the field.
The Advanced tab gives you even more options that you may wish to use to control design and defaults and to control who sees the field.
- Additional CSS Classes – use to style your fields
- Default value – set a default value for your field
- Set Default Value via Parameter – if you wish to use a parameter to set your default value, set it here
- Show to Admins Only? to restrict the field visibility to your site admins
- Restrict access by Capability to select which capabilities have access to the field
When you’re happy with your field click Update Field
The “Labels” tab lets you adjust the Advanced Content Type labels across your admin. These are pre-populated with the name of your Content Type. However, you can adjust them if you want to. Adding a new label to the first two fields will update all of your labels, or you can adjust every label individually.
The “Admin UI” tab gives you fine-tuning options for your Advanced Content Type’s admin menu appearance:
- Choose whether to show your ACT in the Admin Menu, assign a name and an icon
- Specify the menu’s position or parent menu ID
- Select which actions are available (Add New, Edit, Duplicate, Delete, Reorder, Export)
- Select the columns to be shown in the admin table
- Select which fields should provide search filters
Note: Specifying the location for a custom menu icon can be aided by the use of special magic tags.
The “Advanced Options” tab gives you fine-tuning options for your Advanced Content Type. The defaults usually suffice here, but there are a few things you may wish to adjust:
- Use the Detail Page URL to create advanced URL structures and rewrites. To use this option you must have the Pages component activated.
- Select which field should be used as the “title” field
- Set the ACT to be hierarchical
Whenever you’re finished with your fields and your options click Save Pod.