WordPress gives you the means to interact with the built-in post types. It also allows us developers to extend the classification by adding new custom post types. This series shows you what you can do with the post types, both built-in and custom ones.
Docx
WordPress provides a series of functions which allow us developers to work with the built-in post types and extend WordPress via custom post types. You can check if the type exists, add or remove a feature, register a new post type, and more. Take the time to learn these functions and know how to maximize them.
Now you can go deeper into action events:
Hands-on Labs
Let’s build some stuff to learn more about the WordPress custom post types (CPT).
Insights
Here are quick tips and insights all about post types.
Does It Matter If a Hook’s Callback Function Comes Before or After its add_action? No and Yes.
Does it matter if a hook's callback function comes before or after its add_action? My answer might surprise you. No, it does not matter to PHP or WordPress. Yes, it does matter for code readability. I'll explain why in this article.
Developer’s Guide to Differentiating WordPress Content – Taxonomies and Terms
Part 2 of a series on differentiating content. We need a way to provide contextual information about the content and give readers additional mechanisms to explore and discover content. WordPress provides us with taxonomies and their terms.
Developer’s Guide to Differentiating WordPress Content – Post Types
As developers, it can be confusing to understand the intent and role of the mechanisms in WordPress to differentiate content. What are post types, taxonomies and terms, and custom fields? Why do they exist? When do you use the built-in ones? When do you build a custom one? We need a definitive guide that provides structure and best practices for differentiating content. We need a Developer's Guide. In this first part of the series, we'll discuss the why, what, and when of the WordPress post type from both a technical and practical perspectives.
2 Timing Mistakes When Removing a WordPress Callback Hook
You want to remove some callback hook in WordPress. You keep trying, but it's not working. Argh, why isn't it working? Did you know that timing is important? There are two (2) common timing mistakes when removing (or attempt to remove) a WordPress callback hook. Let's explore these timing mistakes and then give you some strategies to master the remove process every single time.
Hooking into WordPress: What the Heck is a Hook?
Actions. Filters. Events. Hooks. You read about these terms all the time in tutorials and codex. You see code snippets with add_action, add_filter, and apply_filters. What the heck is a hook? What does it do? And why should you care about learning the event management system in WordPress? Stop pulling your hair out and give me a few minutes of your time to explain it in layman's terms.
Get Familiar with WordPress Posts Database Table
Have you ever opened up your database? Have you poked around in there to understand the layout and different buckets of content and information? In today’s quick tip, you’ll look at the wp_posts database table. You’ll learn about basic database terminology, such as record, row, primary key, and columns. You’ll see how the columns within a record relate to the content you see in the WordPress back-end.
Yoda Conditions: To Yoda or Not to Yoda
Tonya explains the Yoda conditions programming style. She discusses its intent and the problem it seeks to solve. A handy guide and litmus test are included to help you decide when to use it in your programs. Both PHP and JavaScript examples are provided to test your knowledge.
Code Tip: Specify a default for get_option()
In this quick tip, you will see that you can specify a default return value for the WordPress function get_option(). When the option does not exist in the database, such as you are setting up a theme options page, then you can specify a return value as the default. Otherwise, you will get “false” back.
WordPress Tip: Do You Have to Specify all the Arguments for add_action and add_filter?
The question I often get is: If I only need a couple of the arguments that a filter or action makes available, do I have to specify all of them in the callback function for add_filter() and add_action(). For example, if a filter, such as shortcode_atts_{$shortcode} has 4 arguments, but I only need 3, do I have to wire it up for all 4? In this video, Tonya explains why you have control over what you want to receive by looking into WordPress core at apply_filters().
PHP Tip: Use array_merge and Not foreach to Merge Defaults
In this quick tip, Tonya shows you how to reduce your code when you want to merge default parameters (settings) together with the implement. She shows you a shortcode example from WordPress which uses a foreach() to accomplish what one line of code and do, i.e. using array_merge.
WordPress Tip – Put in the Shortcode Name for shortcode_atts
Help out your fellow developers and put the shortcode name as the third parameter in the function shortcode_atts(). Why? To allow other developers to modify the default attributes you specify with your shortcode. Tonya shows you how this works and the benefit to the site owner.
WordPress Tip – Match Arguments and Parameters When Calling Functions
You have to match the number of arguments to the number of required parameters for a PHP function. A common error is when you forget to specify the number of arguments to send when wiring up an event callback for add_action() or add_filter(). In this video, Tonya shows you why you have to specify this number.
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.