In this episode, you will learn about why, when, what, and how of flushing the rewrite rules for your new custom post type. You’ll learn about permalinks, Rewrite API, and how the page request is mapped through the rewrite rules to figure out what record to pull from the Posts database table. The starter plugin you got at the start of this lab has the rewrite the right way. It’s attached to the plugin activation event. That is the right way to do it. Why? Rebuilding (flushing) rewrites is an expensive process. It takes a lot of time to do […]
In the last episode, you built a function to handle grabbing all of the post’s post type features. But what if you don’t want all of them? It would be nice to make our new function more reusable by passing in features to exclude. In this episode, you’ll extend your new function by adding the exclude option. We want to exclude trackbacks, comments, excerpts, and custom fields features. You can follow along in WordPress codex. You will use the following PHP and WordPress Core functions: get_all_post_type_supports() array_keys() foreach() in_array() continue()
In the last episode, you configured the basic post type features including title, editor, and featured image. Let’s add more. And you’ll see how to go grab all of the available features. You will use the following PHP and WordPress Core functions: get_all_post_type_supports() array_keys() You can follow along in WordPress codex.
You are going to want to configure all the unique labels in the back-end for your client. Listen to me. It’s your job to make it consistent and easy for the user (your client) to use and manage their content. Labels that say “Post” will confuse them. It will confuse you six months from now when you come back to this project. Take the time to configure the labels. It just takes a couple of minutes. In this episode, you will learn about the different label options. You’ll also learn about internationalization with __() and _x(). Since we are building […]
Registering a custom post type takes just a couple lines of code. With two arguments and a slug/key, you are adding our team bios custom post type. It’s very simple. Obviously, you will want more features and functionality. But with that minimum configuration, the starter plugin gives you a team bios CPT. What are public and label arguments? What is the slug/key? In this episode, you are going to change these arguments and see what the results are. Here is the link to the WordPress Register Post Type codex.
Make sure you have installed the plugin into your sandbox project. You can get it from GitHub. Let’s walk through the code in this starter plugin to help you see how it’s organized. In this lab, you will be working within this plugin. Over time, you and I can add more functionality to it, such as a shortcode and template page.
What the heck is a custom post type in WordPress? Why do we need it? How does it differ from the post types that are built into WordPress Core? When do you use it? Let’s talk about what makes a post type “custom.”
Let’s talk about how I found the event name to use to turn the editor back on again in the previous video. Then you’ll look at WordPress Core to see where and how it turns off the editor for the specific Posts Page. You’ll also look at WordPress Core for the function remove_post_type_support. It’s time to reverse engineer WordPress Core.