Screenshot of BuddyBoss Groups


CPTs Can Be a Good Online Approach for Organizing Research

A Custom Post Type (CPT) (also known as a custom content type in a CMS like Drupal) is a grouping of numerous fields together to create an entity. When creating CPTs, the fields are usually filled out in a form. By default in WordPress, forms are displayed in the administrator area. However, the forms can also be displayed in the front end of the website as well. An example of using forms on the front end is the BuddyBlog plugin for use with BuddyBoss. Once the CPT is created, the field values of a CPT can be displayed in various ways depending on the theme used by the given website.

Using a CPT is a good way to encapsulate a research study into pieces that can be more easily managed. For example, a CPT could be used to encapsulate all of the information needed for an experiment or for a step in an experiment or for a survey in a research study. The design and building of appropriate CPTs for a research project involves several considerations, as discussed below.

Determining Required Field Types

When we are using a CMS like WordPress for our ELN, one of our first steps should be to determine whether using the standard WordPress field types like plain text, rich text, dates, tags, taxonomies/categories, and web links will be adequate for our data collection. Ideally, we would have field types that fully reflect the type of data that we are collecting. For example, we could use plain text fields to collect latitude and longitude values, but it is preferable to have field types specific for geolocation if feasible. There are numerous WordPress plugins that allow us to add specific field types. In some specialized cases (e.g., chemical structures) it may be challenging to find plugins that are good enough for the type of data that we want to store. On the other hand, for some research projects the standard field types will be sufficient. Making the assessment of exactly what field types are needed is an important step to make as we begin the process of creating a CPT.

Using Plugins for a CPT

There are many WordPress plugins that allow us to create a CPT without any programming on our part.

Using Custom Software Development for a CPT

If we find that the use of existing WordPress plugins do not meet our needs for creating our desired CPT design, then we can take the approach of using custom programming to create our CPT. If we take this approach, then we should recognize that we will be creating a custom plugin for WordPress. In other words, a CPT is a particular type of a WordPress plugin. The next sections will discuss the options for creating a custom CPT.

Since a custom CPT is a type of a plugin, then we can use the standard plugin design to begin with.

Valuable Resources

  • WordPress Plugin Development - an extensive series of YouTube videos with a supporting GitHub repository by a very knowledgeable and entertaining WordPress developer (Alessandro Castellani) that covers some best practices for building custom WordPress plugins using composer and PS4 standards.
  • WordPress Plugin Boilerplate - provides a GitHub repository with a standard folder structure and files that are based on the WordPress Plugin API, Coding Standards, and Documentation Standards. I followed the basic structure for my plugin, but did not base my code on this example.
  • WordPress Plugin Development Cookbook (3rd Edition) - This book contains recipes for different aspects of creating WordPress plugins. There is also an associated GitHub repository for the code.