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()
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Configure Post Type Features
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.
Configure Labels
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 […]
Minimum Configuration
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.
Plugin Overview
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 is a Custom Post Type?
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.”
WordPress Tip – Linking Taxonomy to Custom Post Type
Do you need to include the optional parameter taxonomies when registering the custom post type register_post_type()? How do you link the taxonomy and post type? In this quick tip, Tonya shows the how and why of the `taxonomies` optional parameter.