By default, a WordPress custom post type does not use the Gutenberg editor. Why? In this quick tip, Tonya walks you through the why and shows you how to enable the Gutenberg editor for your custom post types. Don’t worry. It’s literally one configuration parameter.
Add Another Custom Field
What happens when you need to add another custom field, meaning you have more than one? Let’s set the stage by adding a checkbox to our meta box.
Specify Certain Labels Option
What if someone needs to specify some of the labels, but s/he wants the remaining ones to be generated? Hmmmm, that’s an interesting notion. It seems like a valid optional feature that someone would want from your plugin. Let’s build that feature.
Refactoring the Label Generator
Whew, now it’s time to refactor the label generator function. Our labels are split apart into the three categories. What do we need to do? First, we need to know if we are generating labels for a taxonomy or post type. Then we can merge those together with the shared labels.
In this episode, you and I will move the rewrite rules handler out of the FAQ Module and put it into our new Custom Module. We’ll simplify the process during plugin activation by removing all the code and replacing it with delete_option( ‘rewrite_rules’ );.
Custom Post Type Generator – Registration
Next, you and I need to build a registry mechanism for our custom post type generator. We need a way for plugins to hook into our custom module and pass each custom post type’s configuration to us for processing. Let’s talk about the different approaches to achieve this feature. There are different strategies that we can use: Use the WordPress event-driven engine by building a custom filter We could build a configuration store. For the custom post type, let’s build a custom filter event. Later for the taxonomy, we’ll build a configuration store. Why? I want to give you two […]
Test it Out
Let’s test the registration code for a single custom post type. This test will ensure that our automatic supported features and label generations do work as we expect.
Build the FAQ Custom Post Type Config
I think it will best to start with extracting the runtime configuration parameters out of the codebase and move those into a configuration file. Let’s walk through the process together, step-by-step and talking about the strategy of identifying these parameters, the extraction process, and then how to layout the configuration file.
Generate Post Type Supported Features
We need to improve our plugin’s post type supported features generator. Why? We need to include a mechanism to add new features when configured. Let’s walk through the refactoring process together, step-by-step. In this episode, you will improve the code and remove the specific implementation to make it reusable.
Building Custom Post Type Generator
Let’s start building our central custom post type generator. This is the module that handles: Receiving all of the custom post type configurations in your project Loop through each of them to do the following: Generate the features supported by the custom post type Generate the labels Build the arguments and then register the custom post type with WordPress We’ll start by copying and pasting the code from our FAQ module into the new Custom module. Then we’ll start working on refactoring it. Our goal is to remove all of the specific implementation code, i.e. to make it generic and […]