{"id":4004,"date":"2020-02-13T15:00:46","date_gmt":"2020-02-13T14:00:46","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=4004"},"modified":"2021-09-14T12:00:33","modified_gmt":"2021-09-14T10:00:33","slug":"how-to-make-wordpress-custom-post-types","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/how-to-make-wordpress-custom-post-types\/","title":{"rendered":"What Are Custom Post Types in WordPress and How to Make Them"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]WordPress has long become more than just a simple blogging platform. Over the years, it has grown to become a bona fide Content Management System, with a vast array of options allowing for great flexibility and scalability.<strong> Custom post types<\/strong> are among those possibilities, and today we\u2019re going to explain<strong> what they are, what they can be used for, and how to use them.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">What Are WordPress Custom Post Types<\/h2>\n<p>[\/vc_column_text][vc_column_text]When thinking about WordPress posts, most people think of blog posts or articles, image galleries, video, and audio posts. All these, plus quote and link posts, are actually formats of just one post type that comes with WordPress by default \u2013 the \u201cactual,\u201d regular posts.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]There are <strong>five default post types<\/strong> in WordPress:[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Posts<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Pages<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Attachments<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Revisions<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Navigation menus\n<\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The official WordPress support site has <a href=\"https:\/\/wordpress.org\/support\/article\/post-types\/\" target=\"_blank\" rel=\"noopener\">a detailed explanation for each of these default types<\/a>, but right now we want to focus on custom post types, i.e. those post types that do not fall into any of these categories and which you have to make by yourself if you need them.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]When it comes to blogging, the default WordPress content types are usually enough. But since <a href=\"https:\/\/qodeinteractive.com\/magazine\/global-companies-that-use-wordpress\/\">WordPress started to power all sorts of websites<\/a>, a need for new post types has emerged.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For instance, if you\u2019re running a portfolio website, you may need a <strong>Portfolio custom post type<\/strong>. Businesses and companies need <strong>Testimonials<\/strong>, online shops need <strong>Products<\/strong>, real estate websites need <strong>Property post types<\/strong>, and so on.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now, depending on your theme,<strong> these custom posts may already come out of the box<\/strong>. For instance, your <a href=\"https:\/\/qodeinteractive.com\/theme-category\/listing-wordpress-themes\/\" target=\"_blank\" rel=\"noopener\">listing WordPress theme<\/a> will most likely include Listing items, and these are actually custom post types, created by the theme developer.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"491\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample.jpg\" class=\"attachment-full size-full\" alt=\"Eiddo Sample\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-300x152.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-768x389.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-620x314.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"491\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-2.jpg\" class=\"attachment-full size-full\" alt=\"Eiddo Sample\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-2.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-2-300x152.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-2-768x389.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-2-620x314.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"582\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-3.jpg\" class=\"attachment-full size-full\" alt=\"Eiddo Sample\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-3.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-3-300x180.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-3-768x461.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Eiddo-Sample-3-620x372.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;78px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">When to Use Custom Post Types in WordPress<\/h2>\n<p>[\/vc_column_text][vc_column_text]In theory, you can always just use a default WordPress post type \u2013 a \u201cregular\u201d post or a page \u2013 to publish your content and organize it using tags and categories. But this is not always convenient, especially for niche-related custom content types mentioned above (portfolio items, properties, etc.), or at least it\u2019s not always a great idea.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For instance, there are situations when you want to publish something using the default <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-change-post-type-in-wordpress\/\">post types<\/a> but they just don\u2019t seem to fit your content right. This is the case with coupons, for example. Or, you may find it <strong>difficult to classify and organize<\/strong> the post in question using <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-taxonomy\/\">default WordPress taxonomies<\/a> (that\u2019s why there are custom taxonomies as well, but we\u2019ll get to that in a bit). Also, there are post types that <strong>cannot and should not be displayed chronologically<\/strong>, in your blog roll.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Let\u2019s take an online entertainment magazine. A large portion of the magazine\u2019s content output consists of news. For these, the magazine will most likely use regular WordPress posts. But the magazine also has a section where they review new albums, movies, restaurants, and so on. These can, theoretically, be published as \u201cplain\u201d posts, but in order to add extra features to them (star rating system, search by author, etc), the magazine will most likely have to create a custom post type for reviews.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In simple words \u2013<strong> not all post types fall into one of the default categories<\/strong>. And that\u2019s precisely when you need custom post types.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">How to make a custom post type in WordPress<\/h2>\n<p>[\/vc_column_text][vc_column_text]The process of making custom post types involves different things, so we divided it into four different sections, each with its own detailed explanation. These sections describe the various steps you need to take to properly make a functioning custom post type for your site. As this topic is quite advanced, i.e. it involves coding, you might need to do additional research alongside the explanations we provided if you find yourself stuck.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Before we dive in, we recommend brushing up on your <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-use-ftp\/\">knowledge of FTP<\/a>, as some steps include editing the WordPress files on the server or uploading new ones. <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-manually-backup-wordpress-website\/\">Making a backup of your website<\/a> is also a good precautionary measure since we will be adding new code to our website.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">Registering the custom post type<\/h3>\n<p>[\/vc_column_text][vc_column_text]The first step to creating your custom post type is to register it. And we will cover two ways of performing the registration process, so users of different experience levels can pick the one that suits them. The first involves <strong>using a plugin<\/strong>. With it, you can select all the properties the custom post type will have through an<strong> intuitive plugin user interface<\/strong>. The second involves <strong>using code<\/strong>. It is more complex but it also gives you <strong>more freedom for customizing<\/strong> the new post template.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using a WordPress plugin<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Using a WordPress plugin to add a new feature to a website is very beginner-friendly. This makes it the preferred choice of many WordPress users. For this article, we will show you how to register a custom post template using the <a href=\"https:\/\/wordpress.org\/plugins\/custom-post-type-ui\/\" target=\"_blank\" rel=\"noopener\">Custom Post Types UI (CPT UI) plugin<\/a>. This plugin is by far the most popular plugin for creating your own custom post types. It is free and can be used even by those who don\u2019t know much about coding or advanced WordPress customization.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The plugin allows you to <strong>use the WordPress interface to register and manage custom post types<\/strong>, and it also helps you create <strong>custom taxonomies<\/strong>. This part is particularly important since your website might need additional taxonomies for your posts, not just categories and tags. For example, if you\u2019re running a book website, you can add custom taxonomies for sorting the content by author, genre, location, and so on.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To <strong>add a post type<\/strong>, just follow these simple steps:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-install-a-wordpress-plugin\/\">downloading and installing the plugin<\/a>, you will notice a new option in your WordPress Admin Dashboard, called <strong>CPT UI<\/strong>. From there, simply<strong> click on Add\/Edit Post Types<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"529\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-Edit-Post-Types.jpg\" class=\"attachment-full size-full\" alt=\"Add Edit Post Types\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-Edit-Post-Types.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-Edit-Post-Types-300x164.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-Edit-Post-Types-768x419.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-Edit-Post-Types-620x338.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Under the <strong>Add New Post Type tab, assign a slug to your post type and add plural and singular labels for it.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"585\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/CPT-UI-Basic-Settings.jpg\" class=\"attachment-full size-full\" alt=\"CPT UI Basic Settings\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/CPT-UI-Basic-Settings.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/CPT-UI-Basic-Settings-300x181.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/CPT-UI-Basic-Settings-768x464.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/CPT-UI-Basic-Settings-620x374.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]For example, if your post type is going to be related to the movie industry, the slug should say \u201cmovie,\u201d the plural label should be \u201cMovies\u201d and the singular label will be \u201cMovie\u201d. You can see how that looked on our end from the screenshot above. Also, when you\u2019re picking your labels, make sure to capitalize them.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]At this point,<strong> you can register the custom post type by clicking on the <em>Add Post Type<\/em> button<\/strong>. Your brand new post type will now appear as a separate option in your Dashboard menu.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Dashboard-Movies.jpg\" class=\"attachment-full size-full\" alt=\"Dashboard Movies\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Dashboard-Movies.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Dashboard-Movies-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Dashboard-Movies-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Dashboard-Movies-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>You can also choose to make additional settings to your custom post type before you register it.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Below the Basic settings, you will see a number of fields for entering <strong>Additional labels<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"533\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Additional-Labels.jpg\" class=\"attachment-full size-full\" alt=\"Additional Labels\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Additional-Labels.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Additional-Labels-300x165.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Additional-Labels-768x422.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Additional-Labels-620x341.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]You can fill these in to change the names of default WordPress fields for post management and publishing \u2013 basically create custom fields \u2013 or you can leave them at default.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The section below contains more custom post type settings.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"605\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Settings.jpg\" class=\"attachment-full size-full\" alt=\"Settings\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Settings.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Settings-300x187.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Settings-768x480.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Settings-620x387.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Here, you can set everything from visibility and searchability of your custom post type to menu position, supported post type options, and taxonomies. After you set everything you want, <strong>make sure to register your new custom post type by pressing the <em>Add Post Type<\/em> button at the bottom, if you haven\u2019t done so already.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You can always edit your custom post types later on, by <strong>clicking on the <em>Edit Post Types<\/em> tab<\/strong> and <strong>selecting the post type you want to edit or delete.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"693\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Post-Types.jpg\" class=\"attachment-full size-full\" alt=\"Edit Post Types\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Post-Types.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Post-Types-300x215.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Post-Types-768x549.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Post-Types-620x443.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Next to the Edit Post Types tab, you\u2019ll see two more\u2014<strong>View Post Types<\/strong> and <strong>Import\/Export Post Types<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The <strong>View Post Types<\/strong> tab allows you to see details for all the custom post types you have registered.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"512\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/View-Post-Types.jpg\" class=\"attachment-full size-full\" alt=\"View Post Types\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/View-Post-Types.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/View-Post-Types-300x159.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/View-Post-Types-768x406.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/View-Post-Types-620x328.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The most important information in the View Post Types tab is located at the end, under <strong>Template Hierarchy. It shows the hierarchical approach that WordPress uses for determining which template file is responsible for displaying the content of particular pages and posts.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>The CPT UI plugin displays the hierarchy for the custom post type single post, its archive, and a page belonging to a custom taxonomy once that taxonomy has been registered.<\/strong> As such, it displays the potential names you can use for the files you&#8217;ll be creating. This is a topic we will return to later in the article.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, you can use the <strong>Import\/Export Post Types<\/strong> tab (or the <strong>CPT UI &gt; Tools<\/strong> option in the menu) to migrate (import or export) your registered custom post types.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type.jpg\" class=\"attachment-full size-full\" alt=\"Custom Post Type\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using custom code<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Using code to register your custom single post types constitutes a more technical approach than working with a plugin. Therefore, it can be interesting to intermediate and advanced WordPress users and those who want to learn more. To help explain how the process works, we created an example for this article.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]There are two key points to the registration process. One is the use of the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_post_type\/\" target=\"_blank\" rel=\"noopener\">register_post_type()<\/a> function with the appropriate parameters. The other is the use of an appropriate hook that you can hook that code onto. You can see in the Description section of the <strong>register_post_type()<\/strong> function page that the post type registration shouldn\u2019t be hooked to a hook before <a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/init\/\" target=\"_blank\" rel=\"noopener\">init<\/a>. Therefore, we will use the init action hook as the earliest suitable one. That means a possible pseudocode example would look like this:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">function your-function-name () {\r\n\/\/ Insert the register_post_type() function call here.\r\n}\r\nadd_action( 'init' , 'your-function-name' );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, for this article, we decided to use a marginally more complex approach to registering custom post types. We will be registering our custom post type using object-oriented programming, i.e. within a custom-defined class object. Of course, the same two key points still apply\u2014the use of the <strong>register_post_type()<\/strong> function and hooks. Both will be implemented within that class using the methods, i.e. functions, belonging to that class.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Although slightly more difficult to implement, the benefit of this approach is that the code is easier to read as key things are compartmentalized using class methods. Furthermore, it is easier to scale up a well-structured code by adding new layers of functionalities like taxonomies, shortcodes, or widgets later on. In the example we\u2019ll show you, we added the taxonomies.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you create the proper class structure, the code you put together can be re-used as a blueprint, with minimal edits, to make other custom post types. Before we jump into the coding example prepared for this article, we have to mention where you can put this code. Namely, <strong>code like this should be inserted inside the functions.php file of your child theme or a <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-site-specific-plugin\/\">site-specific plugin<\/a>.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Movie {\r\nprivate static $instance;\r\npublic function __construct() {\r\n$this-&gt;movieBase = 'movie';\r\nadd_action( 'init', array( $this, 'registerMoviePostType' ) );\r\n}\r\npublic static function get_instance() {\r\nif ( ! isset( self::$instance ) &amp;&amp; ! ( self::$instance instanceof self ) ) {\r\nself::$instance = new self();\r\n}\r\nreturn self::$instance;\r\n}\r\npublic function registerMoviePostType() {\r\nregister_post_type( $this-&gt;movieBase,\r\narray(\r\n'labels' =&gt; array(\r\n'name' =&gt; esc_html__( 'Movies', 'your-translate-domain' ),\r\n'singular_name' =&gt; esc_html__( 'Movie', 'your-translate-domain' ),\r\n'add_item' =&gt; esc_html__( 'New Movie', 'your-translate-domain' ),\r\n'add_new_item' =&gt; esc_html__( 'Add New Movie', 'your-translate-domain' ),\r\n'edit_item' =&gt; esc_html__( 'Edit Movie', 'your-translate-domain' )\r\n),\r\n'public' =&gt; true,\r\n'has_archive' =&gt; true,\r\n'rewrite' =&gt; array( 'slug' =&gt; $this-&gt;movieBase ),\r\n'menu_position' =&gt; 5,\r\n'show_ui' =&gt; true,\r\n'show_in_rest' =&gt; true,\r\n'supports' =&gt; array(\r\n'author',\r\n'title',\r\n'editor',\r\n'thumbnail',\r\n'excerpt',\r\n'page-attributes',\r\n'comments',\r\n'custom-fields'\r\n)\r\n)\r\n);\r\n}\r\n}\r\nMovie::get_instance();<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Let\u2019s break this code down.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Simply put, the code represents a custom class called <em>Movie<\/em> with one property called <strong>$instance<\/strong> and three methods: <strong>__construct(), get_instance()<\/strong>, and <strong>registerMoviePostType()<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The<strong> get_instance()<\/strong> method is used to instantiate an instance of the <em>Movie<\/em> class, which is done at the end of the code by calling that method. As such, the main part of the code lies in the other two class methods, i.e. functions.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The <strong>__construct()<\/strong> method is the constructor method for the <em>Movie<\/em> class and it only has two lines of code. The first defines a property named <strong>movieBase<\/strong>, which is, in fact, the slug of the custom post type we wish to register. Technically speaking, this line of code isn\u2019t necessary, we included it for the sake of convenience. As the post slug often needs to be repeated in various functions, having it stored into one variable makes the process of changing it later on easier.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As for the second line, it represents the use of the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/\" target=\"_blank\" rel=\"noopener\">add_action()<\/a> function where we hooked the <strong>registerMoviePostType()<\/strong> method to the <a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/init\/\" target=\"_blank\" rel=\"noopener\">init<\/a> action hook. This hook is the earliest hook that can be used for registering custom post types. And for everything to work properly, we used the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_post_type\/\" target=\"_blank\" rel=\"noopener\">register_post_type()<\/a> function to register our movie post type.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]When registering the movie post type, we specified the following attributes: <strong>an array of labels that display in the backend, made the movie post type publicly available in the frontend, enabled the archive page, enabled permalink rewrites, and set the slug to \u2018movie\u2019.<\/strong> We also<strong> enabled the user interface for movie handling in the admin area and set its position to 5, which will ensure that the section will be placed higher up in the admin\u2019s left side menu, right below Posts.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Moreover, <strong>we enabled the REST API for this custom post type, which is one of the two requirements for enabling Gutenberg as the editor for this custom post type<\/strong>. Then, using the supports property, <strong>we enabled the title, author, the option to insert content using the editor (which is the second requirement for Gutenberg), a featured image, and the option to insert an excerpt<\/strong>. We also enabled<strong> the Page (i.e. Post) Attributes section that displays the menu order field, as well as the comment section and the option to use custom fields within this post type.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Besides the ones we mentioned above, there are a lot more parameters you can use. You can get an idea of what those are from the previous section by examining the CPT UI plugin options. To get a more precise overview of all the currently available parameters, you should review <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_post_type\/#parameter-detail-information\" target=\"_blank\" rel=\"noopener\">the detailed information<\/a> section from the <strong>register_post_type()<\/strong> function page.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">Registering a custom taxonomy<\/h3>\n<p>[\/vc_column_text][vc_column_text]After registering a custom post type, the next thing you should do is register the taxonomies that are associated with it. Taxonomies allow you to group various post items, giving structure to your content while helping your visitors find what they want easily. Most users are very familiar with categories and tags, which are the two <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-taxonomy\/\">default WordPress taxonomies<\/a>. However, you might feel like these two won\u2019t represent your custom post type well. In that case, registering a custom taxonomy is the best solution.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As part of this article, we will show you how to register a <strong>movie genre<\/strong> as a custom taxonomy. Given that we\u2019re creating a movie custom post type, a taxonomy that matches the niche would be a perfect fit. Much as we did in the previous section, we will show you how this process goes using either the CPT UI plugin or custom code.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using a WordPress plugin<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Adding taxonomies with the CPT UI plugin is quite easy, you just need to follow the steps below.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Navigate to the CPT UI admin section and click on Add\/Edit Taxonomies.<\/strong> Then, under the <strong>Add New Taxonomy tab, assign a taxonomy slug and plural and singular labels.<\/strong> The slug should use Latin and alphanumeric characters, and the labels should be capitalized. Also, please note that the plugin won\u2019t allow you to use a dash\u2014it will be replaced with an underscore instead.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you fill in those fields, <strong>make sure to tick the checkbox next to the label of the custom post type that you want to tie this taxonomy to<\/strong>. In our case, that was the <em>Movies<\/em> label.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After that, <strong>you can opt to register the custom taxonomy by clicking on Add Taxonomy.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Adding-Taxonomy.jpg\" class=\"attachment-full size-full\" alt=\"Adding Taxonomy\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Adding-Taxonomy.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Adding-Taxonomy-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Adding-Taxonomy-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Adding-Taxonomy-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then, the new taxonomy will appear in the Dashboard menu, under the Movies section that it\u2019s tied to.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Genres.jpg\" class=\"attachment-full size-full\" alt=\"Movies Genres\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Genres.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Genres-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Genres-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Genres-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]However,<strong> there are additional settings you can add to your taxonomy before registering it, as you can see in the section below.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Underneath the Basic settings, you will see a number of fields for entering<strong> Additional labels<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"689\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Additional-Labels.jpg\" class=\"attachment-full size-full\" alt=\"Taxonomy Additional Labels\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Additional-Labels.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Additional-Labels-300x213.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Additional-Labels-768x546.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Additional-Labels-620x441.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The section below it, titled Settings, allows you to set the parameters for your custom taxonomy.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Settings.jpg\" class=\"attachment-full size-full\" alt=\"Taxonomy Settings\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Settings.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Settings-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Settings-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomy-Settings-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]And, <strong>if you haven\u2019t done so already, make sure to register the taxonomy by pressing the Add Taxonomy button at the bottom.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As we mentioned in our section on registering post types, you can always make edits later on. In this case, you can do so<strong> by clicking on the Edit Taxonomies tab<\/strong> and <strong>selecting the taxonomy you want to edit or delete.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Taxonomy.jpg\" class=\"attachment-full size-full\" alt=\"Edit Taxonomy\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Taxonomy.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Taxonomy-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Taxonomy-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Edit-Taxonomy-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Also, as before, you\u2019ll have two extra tabs available. The <strong>View Taxonomies<\/strong> tab allows you to see details for all the taxonomies you have registered. <strong>To locate the information on a registered taxonomy, you need to scroll down to the Taxonomies section and find the appropriate taxonomy within the list of those currently registered.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"541\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomies.jpg\" class=\"attachment-full size-full\" alt=\"Taxonomies\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomies.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomies-300x167.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomies-768x429.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Taxonomies-620x346.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The Template Hierarchy column is present here as well, and it provides information on the template hierarchy for taxonomy files. Meaning, it contains potential file names you can use for the file that will help you display the content of a given taxonomy.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, you can use the<strong> Import\/Export Taxonomies<\/strong> tab (or the <strong>CPT UI &gt; Tools<\/strong> option in the menu) to migrate (import or export) your registered taxonomies.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-Taxonomies.jpg\" class=\"attachment-full size-full\" alt=\"Custom Post Type Taxonomies\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-Taxonomies.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-Taxonomies-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-Taxonomies-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Custom-Post-Type-Taxonomies-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Using custom code<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Similar to registering a custom post type with code, the process of registering custom taxonomies relies on the two key points. One is the use of the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_taxonomy\/\" target=\"_blank\" rel=\"noopener\">register_taxonomy()<\/a> function with appropriate parameters within the code, and the other is the process of hooking the code onto an appropriate action hook. As earlier, you shouldn\u2019t use any hook that is loaded before the <strong>init<\/strong> hook. Thus, the pseudocode for this process would look this:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">function your-function-name () {\r\n\/\/ Insert the register_taxonomy() function call here.\r\n}\r\nadd_action( 'init' , 'your-function-name' );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, earlier we decided to use object-oriented programming for this article, and we will stick to that now by using our movie custom post type example, i.e. the Movie class object. Therefore, <strong>we only need to update the existing code with additional properties and methods that help us register our movie genre taxonomy and tie it to the movie custom post type<\/strong>. We also need to include the two key points, which enable this process, in our additional code.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]With that in mind, we created the updated version of the earlier code, which registers both the movie post type and movie genre taxonomy within the Movie class object. This code, much like its first version, <strong>should be inserted inside the functions.php file of your child theme or a site-specific plugin<\/strong>. Having said that, you can find the new code snippet below.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Movie {\r\nprivate static $instance;\r\npublic function __construct() {\r\n$this-&gt;movieBase = 'movie';\r\n$this-&gt;genreBase = 'movie_genre';\r\nadd_action( 'init' , array( $this, 'registerMoviePostType' ));\r\nadd_action( 'init' , array( $this, 'registerMovieGenreTax' ));\r\n}\r\npublic static function get_instance() {\r\nif ( ! isset( self::$instance ) &amp;&amp; ! ( self::$instance instanceof self ) ) {\r\nself::$instance = new self();\r\n}\r\nreturn self::$instance;\r\n}\r\npublic function registerMoviePostType() {\r\nregister_post_type( $this-&gt;movieBase,\r\narray(\r\n'labels' =&gt; array(\r\n'name' =&gt; esc_html__( 'Movies', 'your-translate-domain' ),\r\n'singular_name' =&gt; esc_html__( 'Movie', 'your-translate-domain' ),\r\n'add_item' =&gt; esc_html__( 'New Movie', 'your-translate-domain' ),\r\n'add_new_item' =&gt; esc_html__( 'Add New Movie', 'your-translate-domain' ),\r\n'edit_item' =&gt; esc_html__( 'Edit Movie', 'your-translate-domain' )\r\n),\r\n'public' =&gt; true,\r\n'has_archive' =&gt; true,\r\n'rewrite' =&gt; array( 'slug' =&gt; $this-&gt;movieBase ),\r\n'menu_position' =&gt; 5,\r\n'show_ui' =&gt; true,\r\n'show_in_rest' =&gt; true,\r\n'supports' =&gt; array(\r\n'author',\r\n'title',\r\n'editor',\r\n'thumbnail',\r\n'excerpt',\r\n'page-attributes',\r\n'comments',\r\n'custom-fields'\r\n)\r\n)\r\n);\r\n}\r\npublic function registerMovieGenreTax() {\r\n$genre_labels = array(\r\n'name' =&gt; esc_html__( 'Genres', 'your-translate-domain' ),\r\n'singular_name' =&gt; esc_html__( 'Genre', 'your-translate-domain' ),\r\n'search_items' =&gt; esc_html__( 'Genres', 'your-translate-domain' ),\r\n'all_items' =&gt; esc_html__( 'Genres', 'your-translate-domain' ),\r\n'parent_item' =&gt; esc_html__( 'Parent Genre', 'your-translate-domain' ),\r\n'parent_item_colon' =&gt; esc_html__( 'Parent Genres:', 'your-translate-domain' ),\r\n'edit_item' =&gt; esc_html__( 'Edit Genre', 'your-translate-domain' ),\r\n'update_item' =&gt; esc_html__( 'Update Genre', 'your-translate-domain' ),\r\n'add_new_item' =&gt; esc_html__( 'Add New Genre', 'your-translate-domain' ),\r\n'new_item_name' =&gt; esc_html__( 'New Genre', 'your-translate-domain' ),\r\n'menu_name' =&gt; esc_html__( 'Genres', 'your-translate-domain' ),\r\n);\r\nregister_taxonomy( $this-&gt;genreBase, array( $this-&gt;movieBase ), array(\r\n'hierarchical' =&gt; true,\r\n'labels' =&gt; $genre_labels,\r\n'show_ui' =&gt; true,\r\n'show_admin_column' =&gt; true,\r\n'show_in_rest' =&gt; true\r\n) );\r\n}\r\n}\r\nMovie::get_instance();<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]If you compare this snippet to the previous one, you\u2019ll notice we added three parts to the code. Those three new parts enable us to register the movie genre as a taxonomy related to the movie custom post type.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this snippet, we stored the taxonomy slug <strong>movie_genre<\/strong> in a property called <strong>genreBase<\/strong> for the sake of convenience. Then, we created a function called <strong>registerMovieGenreTax()<\/strong>, which is responsible for registering our custom taxonomy. This is done by calling the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_taxonomy\/\" target=\"_blank\" rel=\"noopener\">register_taxonomy()<\/a> function.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The movie genre taxonomy is defined with the <strong>movie_genre<\/strong> taxonomy slug and it\u2019s tied to the movie post type alone because we specified the movie slug as the second argument. Besides that, we defined an array of additional arguments relating to the properties this taxonomy will have. These include <strong>being hierarchical (i.e. able to define subgenres), using previously defined labels, having a user interface for managing genres, having an admin column on the associated post type (<em>movie<\/em>), and exposing the taxonomy to the REST API.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For the registration process to work properly, we hooked the <strong>registerMovieGenreTax()<\/strong> function to the <strong>init<\/strong> action hook by adding the extra line to the <strong>__construct()<\/strong> method within the Movie class.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, as with the previous example, there are additional arguments we could have used. You can see what those are in the CPT UI plugin section. And, to learn more about all the available arguments the <strong>register_taxonomy()<\/strong> function can take, you can review the function\u2019s <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_taxonomy\/#additional-parameter-information\" target=\"_blank\" rel=\"noopener\">additional information section<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">Adding custom post items<\/h3>\n<p>[\/vc_column_text][vc_column_text]After registering the movie custom post type and corresponding movie genre taxonomy, the next step is to create the items that would belong to them. This is done using the WordPress user interface and the Movies section located in the admin dashboard. Before we start, make sure that you set the <strong>show_ui<\/strong> property to <em>true<\/em> while registering the post type and taxonomy as it\u2019s a requirement for this step. After that, you can proceed.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To add a new movie item, <strong>navigate to the Movies section that you created<\/strong> and <strong>select the <em>Add New<\/em> option<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"518\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Add-New.jpg\" class=\"attachment-full size-full\" alt=\"Movies Add New\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Add-New.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Add-New-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Add-New-768x411.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Movies-Add-New-620x331.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Next, you will be given various sections which you can fill with information relevant to that movie item. As part of this article, we created the example you can see below. We framed the sections that we used in red. They include the<strong> title, editor, genre selection, featured image, excerpt<\/strong>, and two custom fields<strong>\u2014qode-movie-cast<\/strong> and <strong>qode-movie-release-date\u2014<\/strong>that we defined and filled with relevant information.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"773\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections.jpg\" class=\"attachment-full size-full\" alt=\"Used Sections\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-300x239.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-768x613.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-620x495.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;60px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"773\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-2.jpg\" class=\"attachment-full size-full\" alt=\"Used Sections\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-2.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-2-300x239.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-2-768x613.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Used-Sections-2-620x495.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]In the same way, you can add your content to any already defined custom post type. And, please note, you will only be able to edit the sections that you previously defined using the <strong>supports<\/strong> property.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]There are two more points we have to mention.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Firstly,<strong> to assign a movie genre to a specific movie item, you will need to create the genre items beforehand from the Movies &gt; Genres &gt; Add New Genre section<\/strong>. This is done by<strong> inserting the name of the genre<\/strong> at a minimum and <strong>clicking on the <em>Add New Genre<\/em> button.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"625\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-New-Genre.jpg\" class=\"attachment-full size-full\" alt=\"Add New Genre\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-New-Genre.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-New-Genre-300x193.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-New-Genre-768x495.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Add-New-Genre-620x400.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Secondly,<strong> if you can\u2019t see the <em>Custom Fields<\/em> section even though it\u2019s enabled for your custom post type, make sure that the panel is set to be displayed within the <em>Preferences<\/em> sectio<\/strong>n. To do that, you need to open the edit screen, <strong>click on the three dots in the top right corner,<\/strong> and <strong>select the <em>Preferences<\/em> option<\/strong> from the menu that opens.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"700\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences.jpg\" class=\"attachment-full size-full\" alt=\"Preferences\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-300x217.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-768x555.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-620x448.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This will open the <em>Preferences<\/em> popup window. Within it, <strong>click on the <em>Panels<\/em> tab<\/strong> and <strong>locate the <em>Custom fields<\/em> option from the <em>Additional<\/em> section<\/strong>. Make sure the option for <em>Custom fields<\/em> is enabled so they can show on your end.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"545\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-Panels.jpg\" class=\"attachment-full size-full\" alt=\"Preferences Panels\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-Panels.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-Panels-300x169.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-Panels-768x432.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Preferences-Panels-620x349.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Finally, <strong>after adding your content, make sure to publish the custom post item by pressing the <em>Publish<\/em> button in the top right corner.<\/strong> This brings us to the last and most important step in the process of making custom post types\u2014displaying the content we added to our custom post items.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">Displaying custom post items<\/h3>\n<p>[\/vc_column_text][vc_column_text]To display the movie items that we already created and populated with content, we first have to cover a very important concept\u2014the <a href=\"https:\/\/developer.wordpress.org\/themes\/basics\/template-hierarchy\/\" target=\"_blank\" rel=\"noopener\">Template Hierarchy<\/a>. We mentioned it briefly earlier in the article, but taking a closer look at it now will help us understand which template file is responsible for displaying the content of the corresponding post type.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Understanding Template Hierarchy <\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The template file hierarchy for custom post types is as follows:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]- custom page\/post template file<\/p>\n<p>&#8211; single-{post-type}-{post-slug}.php<\/p>\n<p>&#8211; single-{post-type}.php<\/p>\n<p>&#8211; single.php<\/p>\n<p>&#8211; singular.php<\/p>\n<p>&#8211; index.php[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The {post-type} notation represents the slug of a specific post type, default or custom. The {post-slug} notation represents the slug of a specific post item belonging to that post type. The {post-slug} is used if you want to create a template file that displays only the content of a specific custom post item, and not the content of all items belonging to that post type.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For our movie custom post type, which has the word movie as its slug, the same template hierarchy be:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]- custom page\/post template file<\/p>\n<p>&#8211; single-movie-{post-slug}.php<\/p>\n<p>&#8211; single-movie.php<\/p>\n<p>&#8211; single.php<\/p>\n<p>&#8211; singular.php<\/p>\n<p>&#8211; index.php[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To determine which template file to use for displaying our movie item(s), WordPress needs to go down this list, inspecting which of the files exist on your server. Then, after figuring out which of the files exist, the highest in the hierarchy will be used for displaying the movie item content. Therefore,<strong> to display a custom post type item, you need to create a suitable template file with appropriate code that adheres to this template hierarchy<\/strong>. Then, you should <strong>upload this file to the server in a location we will discuss shortly.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To clarify, you need to create an appropriate template file because otherwise, WordPress will use one of the fallback files that exist within your theme (single.php, singular.php, or index.php). If that happens, any custom content you might have inserted (for example, movie genres, cast members, release date, etc.) won\u2019t be shown as there will be no code within those files for displaying it. And the layout provided by an alternative file might not suit your tastes or be appropriate for that custom post type.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]For this article, we prepared a custom template file that will help us display the content we inserted. You can follow our example or you can create one of the other two possible files, which are single-{post-type}-{post-slug}.php and single-{post-type}.php. We are creating a custom page\/post template file as it will give us the most flexibility, given that it is at the top of the custom post type template hierarchy.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]With that being said, we have to mention that the plugin we\u2019ve used for the registration process, <strong>CPT UI<\/strong>, won\u2019t be used for this last step. While CPT UI has a premium version that helps you display content, it does so by using a custom shortcode. Since that\u2019s not the direction we want to go in this article, we will focus on the code we have prepared.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As you can see from the list above, the template hierarchy for custom post types has a very strict naming convention for all files except the first one. Since the WordPress 4.7 update, users have been able to create <a href=\"https:\/\/qodeinteractive.com\/magazine\/create-wordpress-custom-page-template\/\">custom page templates<\/a> that can be applied for posts or custom post types. These files would be located at the top of the corresponding template file hierarchy.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The only requirement for making a custom page template is having a properly defined template header. To clarify, a template header is a simple comment that specifies the template name and other important information regarding the custom template. For example, if you create a <a href=\"https:\/\/qodeinteractive.com\/magazine\/create-wordpress-single-post-templates\/\">custom template for posts or custom post types<\/a>, like our movie, you will need to specify the post types that this template will be available for. In that case, your template header would look something like this:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\/*\r\nTemplate Name: Full-Width Layout\r\nTemplate Post Type: post, page, movie\r\n*\/<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Using this example template header, we can register a custom page or post template called<em> Full-Width Layout<\/em> that could be used for pages, posts, and movies. In this way, you can register a custom template for any post type or an array of post types.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, just using a template header isn\u2019t all\u2014<strong>you will still need to add the code responsible for displaying content<\/strong>. Then, both the code and the corresponding template header should be <strong>placed in a separate file and uploaded to the server<\/strong> to a location where custom page\/post templates are recognized. As the whole process is best described using an example, we created a template file specifically for this article.[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Custom template file example<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this section, you can find the code we put together to create our custom template file. This file will help us display all the various pieces of content that we inserted in the previous steps.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\/*\r\n* Template Name: Movie Single Layout\r\n* Template Post Type: movie\r\n*\/\r\nget_header();\r\n?&gt;\r\n&lt;main id=\"qodef-page-content\"\r\nclass=\"qodef-layout--template\"\r\nrole=\"main\"&gt;\r\n&lt;div class=\"qodef-grid-inner\"&gt;\r\n&lt;div class=\"qodef-grid-item\"&gt;\r\n&lt;div class=\"qodef-movie-holder\"&gt;\r\n&lt;?php\r\nif ( have_posts() ) {\r\nwhile ( have_posts() ) :\r\nthe_post(); ?&gt;\r\n&lt;article &lt;?php post_class( 'qodef-movie-item' ); ?&gt;&gt;\r\n&lt;div class=\"qodef-e-inner\"&gt;\r\n&lt;?php if ( has_post_thumbnail() ) { ?&gt;\r\n&lt;div class=\"qodef-e-media\"&gt;\r\n&lt;div class=\"qodef-featured-image\"&gt;\r\n&lt;?php $item_id = get_the_ID();\r\necho get_the_post_thumbnail( $item_id, 'large' ); ?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;?php } ?&gt;\r\n&lt;div class=\"qodef-e-content\"&gt;\r\n&lt;div class=\"qodef-e-content-inner\"&gt;\r\n&lt;div class=\"qodef-e-content-text\"&gt;&lt;?php the_content(); ?&gt;&lt;\/div&gt;\r\n&lt;div class=\"qodef-e-info-items\"&gt;\r\n&lt;?php\r\n$movie_genre = get_the_terms( get_the_ID(), 'movie_genre' );\r\nif ( ! empty( $movie_genre ) &amp;&amp; ! is_wp_error( $movie_genre ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-genre\"&gt;&lt;?php echo esc_html__( 'Genre: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-genre-values\"&gt;\r\n&lt;?php foreach ( $movie_genre as $genre_value ) { ?&gt;\r\n&lt;a itemprop=\"url\" class=\"qodef-e-genre-link\"\r\nhref=\"&lt;?php echo esc_url( get_term_link( $genre_value-&gt;term_id ) ); ?&gt;\"&gt;&lt;?php echo esc_html( $genre_value-&gt;name ); ?&gt;&lt;\/a&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php $movie_cast = get_post_meta( $item_id, 'qode-movie-cast', true );\r\n\/\/ Check if the custom field has a value.\r\nif ( ! empty( $movie_cast ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-cast\"&gt;&lt;?php esc_html_e( 'Top cast: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-cast-value\"&gt;&lt;?php echo esc_html( $movie_cast ); ?&gt;&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php $movie_release_date = get_post_meta( $item_id, 'qode-movie-release-date', true );\r\n\/\/ Check if the custom field has a value.\r\nif ( ! empty( $movie_release_date ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-release-date\"&gt;&lt;?php esc_html_e( 'Release date: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-release-date-value\"&gt;&lt;?php echo esc_html( $movie_release_date ); ?&gt;&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=\"qodef-e-navigation\"&gt;\r\n&lt;?php\r\n$post_navigation = array(\r\n'prev' =&gt; array(\r\n'label' =&gt; '&lt;span class=\"qodef-e-navigation-item-label\"&gt;' . esc_html__( '&lt; Prev', 'your-translate-domain' ) . '&lt;\/span&gt;'\r\n),\r\n'next' =&gt; array(\r\n'label' =&gt; '&lt;span class=\"qodef-e-navigation-item-label\"&gt;' . esc_html__( 'Next &gt;', 'your-translate-domain' ) . '&lt;\/span&gt;'\r\n),\r\n);\r\nif ( get_adjacent_post( false, '', true ) !== '' ) {\r\n$post_navigation['prev']['post'] = get_adjacent_post( false, '', true );\r\n}\r\nif ( get_adjacent_post( false, '', false ) !== '' ) {\r\n$post_navigation['next']['post'] = get_adjacent_post( false, '', false );\r\n}\r\nforeach ( $post_navigation as $key =&gt; $value ) {\r\nif ( isset( $post_navigation[ $key ]['post'] ) ) {\r\n$current_post = $value['post'];\r\n$post_id = isset( $value['post_id'] ) &amp;&amp; ! empty( $value['post_id'] ) ? $value['post_id'] : $current_post-&gt;ID;\r\n?&gt;\r\n&lt;a itemprop=\"url\"\r\nclass=\"qodef-e-navigation-item qodef--&lt;?php echo esc_attr( $key ); ?&gt;\"\r\nhref=\"&lt;?php echo esc_url( get_permalink( $post_id ) ); ?&gt;\"&gt;\r\n&lt;?php\r\nif ( ! empty( $value['label'] ) ) {\r\necho wp_kses( $value['label'], array( 'span' =&gt; array( 'class' =&gt; true ) ) );\r\n}\r\n?&gt;\r\n&lt;\/a&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/article&gt;\r\n&lt;?php endwhile; \/\/ End of the loop.\r\n} else { ?&gt;\r\n&lt;p class=\"qodef-m-posts-not-found\"&gt;&lt;?php esc_html_e( 'No posts were found for provided query parameters.', 'your-translate-domain' ); ?&gt;&lt;\/p&gt;\r\n&lt;?php }\r\nwp_reset_postdata();\r\n?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/main&gt;\r\n&lt;?php\r\nget_footer();<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Let\u2019s take a closer look at this code. To make it easier to grasp, we\u2019ll examine it in a simplified form.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]From the template header at the top, you can see the code represents a template called <em>Movie Single Layout<\/em>, which is only applicable to our movie custom post type. After the template header, we have the main part of the code. You can find a <strong>pared-down version of it below.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The header and footer templates defined within your current theme are displayed using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_header\/\" target=\"_blank\" rel=\"noopener\">get_header()<\/a> and <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_footer\/\" target=\"_blank\" rel=\"noopener\">get_footer()<\/a> functions. Besides that, we can see an HTML structure that contains a simple <a href=\"https:\/\/developer.wordpress.org\/themes\/basics\/the-loop\/\" target=\"_blank\" rel=\"noopener\">WordPress Loop<\/a>. If the conditions of that loop are met, then the rest of the code is executed. Otherwise, a message stating <em>\u201cNo posts were found for provided query parameters.\u201d<\/em> will be shown. Additionally, we restored the <strong>$post<\/strong> global variable to the current post in the main query using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_reset_postdata\/\" target=\"_blank\" rel=\"noopener\">wp_reset_postdata()<\/a> function.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\/*\r\n* Template Name: Movie Single Layout\r\n* Template Post Type: movie\r\n*\/\r\nget_header();\r\n?&gt;\r\n&lt;main id=\"qodef-page-content\"\r\nclass=\"qodef-layout--template\"\r\nrole=\"main\"&gt;\r\n&lt;div class=\"qodef-grid-inner\"&gt;\r\n&lt;div class=\"qodef-grid-item\"&gt;\r\n&lt;div class=\"qodef-movie-holder\"&gt;\r\n&lt;?php\r\nif ( have_posts() ) {\r\nwhile ( have_posts() ) :\r\nthe_post(); ?&gt;\r\n&lt;!-- Some code goes here--&gt;\r\n&lt;?php endwhile; \/\/ End of the loop.\r\n} else { ?&gt;\r\n&lt;p class=\"qodef-m-posts-not-found\"&gt;&lt;?php esc_html_e( 'No posts were found for provided query parameters.', 'your-translate-domain' ); ?&gt;&lt;\/p&gt;\r\n&lt;?php }\r\nwp_reset_postdata();\r\n?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/main&gt;\r\n&lt;?php\r\nget_footer();<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Looking at the code located within the WordPress Loop, we can see it represents the content, stored within the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/article\" target=\"_blank\" rel=\"noopener\">&lt;article&gt;<\/a> HTML tag, that each movie item will display. We added a list of WordPress-defined CSS classes, to the &lt;article&gt; element alongside our <strong>qodef-movie-item<\/strong> by using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/post_class\/\" target=\"_blank\" rel=\"noopener\">post_class()<\/a> function. We can use these CSS classes later for creating any CSS code that might be needed for stylization.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As for the content, the &lt;article&gt; <strong>contains three distinct parts. First<\/strong>, as long as<strong> a featured image<\/strong> is added to the custom post item\u2019s content, it will be displayed. This is accomplished thanks to the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_post_thumbnail\/\" target=\"_blank\" rel=\"noopener\">get_the_post_thumbnail()<\/a> function, and the image will be shown in the predefined \u2018large\u2019 image size.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>The second part<\/strong> can be divided into two smaller parts. Those <strong>are the content added to the editor<\/strong> and displayed thanks to <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/the_content\/\" target=\"_blank\" rel=\"noopener\">the_content()<\/a> function, <strong>and the information items<\/strong> that we added to the movie item. In our example, these are the genres to which the movie belongs, its top cast, and scheduled release date. Incidentally, these are the two custom fields that we defined previously.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, <strong>the third part displays the navigation<\/strong>. This will be the previous\/next post navigation, which allows visitors to navigate through your movie post items.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;article &lt;?php post_class( 'qodef-movie-item' ); ?&gt;&gt;\r\n&lt;div class=\"qodef-e-inner\"&gt;\r\n&lt;?php if ( has_post_thumbnail() ) { ?&gt;\r\n&lt;div class=\"qodef-e-media\"&gt;\r\n&lt;div class=\"qodef-featured-image\"&gt;\r\n&lt;?php $item_id = get_the_ID();\r\necho get_the_post_thumbnail( $item_id, 'large' ); ?&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;?php } ?&gt;\r\n&lt;div class=\"qodef-e-content\"&gt;\r\n&lt;div class=\"qodef-e-content-inner\"&gt;\r\n&lt;div class=\"qodef-e-content-text\"&gt;&lt;?php the_content(); ?&gt;&lt;\/div&gt;\r\n&lt;div class=\"qodef-e-info-items\"&gt;\r\n&lt;!-- Some code goes here--&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=\"qodef-e-navigation\"&gt;\r\n&lt;!-- Some code goes here--&gt;\r\n&lt;\/div&gt;\r\n&lt;\/article&gt;<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]We\u2019ll briefly explain the last two sections. The movie genres that the movie is associated with are displayed by using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_terms\/\" target=\"_blank\" rel=\"noopener\">get_the_terms()<\/a> function. And they are linked to the corresponding genre taxonomy page through the use of the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_term_link\/\" target=\"_blank\" rel=\"noopener\">get_term_link()<\/a> function.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The <strong>qode-movie-cast<\/strong> and <strong>qode-movie-release-date<\/strong> custom fields are displayed by using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\" rel=\"noopener\">get_post_meta()<\/a> function. Additionally, all three properties\u2014the genre values, movie cast, and release date\u2014are displayed only if they are added to the post in the preceding step. This is achieved by wrapping each coding section with a corresponding <a href=\"https:\/\/www.php.net\/manual\/en\/control-structures.if.php\" target=\"_blank\" rel=\"noopener\">if statement<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"qodef-e-info-items\"&gt;\r\n&lt;?php\r\n$movie_genre = get_the_terms( get_the_ID(), 'movie_genre' );\r\nif ( ! empty( $movie_genre ) &amp;&amp; ! is_wp_error( $movie_genre ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-genre\"&gt;&lt;?php echo esc_html__( 'Genre: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-genre-values\"&gt;\r\n&lt;?php foreach ( $movie_genre as $genre_value ) { ?&gt;\r\n&lt;a itemprop=\"url\" class=\"qodef-e-genre-link\"\r\nhref=\"&lt;?php echo esc_url( get_term_link( $genre_value-&gt;term_id ) ); ?&gt;\"&gt;&lt;?php echo esc_html( $genre_value-&gt;name ); ?&gt;&lt;\/a&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php $movie_cast = get_post_meta( $item_id, 'qode-movie-cast', true );\r\n\/\/ Check if the custom field has a value.\r\nif ( ! empty( $movie_cast ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-cast\"&gt;&lt;?php esc_html_e( 'Top cast: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-cast-value\"&gt;&lt;?php echo esc_html( $movie_cast ); ?&gt;&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php $movie_release_date = get_post_meta( $item_id, 'qode-movie-release-date', true );\r\n\/\/ Check if the custom field has a value.\r\nif ( ! empty( $movie_release_date ) ) { ?&gt;\r\n&lt;h5 class=\"qodef-e-release-date\"&gt;&lt;?php esc_html_e( 'Release date: ', 'your-translate-domain' ); ?&gt;\r\n&lt;span class=\"qodef-e-release-date-value\"&gt;&lt;?php echo esc_html( $movie_release_date ); ?&gt;&lt;\/span&gt;\r\n&lt;\/h5&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As for the navigation, it is displayed thanks to the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_adjacent_post\/\" target=\"_blank\" rel=\"noopener\">get_adjacent_post()<\/a> function. We also haven\u2019t filtered the items based on a specific taxonomy or excluded any from being queried. Meaning, <strong>the navigation will go through all the movies based on the publishing date<\/strong>, in descending order.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Furthermore, we defined the labels as <em>&lt; Prev<\/em> and <em>Next &gt;<\/em> and placed them inside the <strong>$post_navigation<\/strong> variable, which is an associative array. Then, using a <a href=\"https:\/\/www.php.net\/manual\/en\/control-structures.foreach.php\" target=\"_blank\" rel=\"noopener\">foreach loop<\/a>, the appropriate navigation is displayed. It\u2019s worth mentioning that the navigation labels have been sanitized with the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_kses\/\" target=\"_blank\" rel=\"noopener\">wp_kses()<\/a> function, which is just one of the several functions that we used in code for <a href=\"https:\/\/developer.wordpress.org\/themes\/theme-security\/data-sanitization-escaping\/\" target=\"_blank\" rel=\"noopener\">sanitization purposes<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"qodef-e-navigation\"&gt;\r\n&lt;?php\r\n$post_navigation = array(\r\n'prev' =&gt; array(\r\n'label' =&gt; '&lt;span class=\"qodef-e-navigation-item-label\"&gt;' . esc_html__( '&lt; Prev', 'your-translate-domain' ) . '&lt;\/span&gt;'\r\n),\r\n'next' =&gt; array(\r\n'label' =&gt; '&lt;span class=\"qodef-e-navigation-item-label\"&gt;' . esc_html__( 'Next &gt;', 'your-translate-domain' ) . '&lt;\/span&gt;'\r\n),\r\n);\r\nif ( get_adjacent_post( false, '', true ) !== '' ) {\r\n$post_navigation['prev']['post'] = get_adjacent_post( false, '', true );\r\n}\r\nif ( get_adjacent_post( false, '', false ) !== '' ) {\r\n$post_navigation['next']['post'] = get_adjacent_post( false, '', false );\r\n}\r\nforeach ( $post_navigation as $key =&gt; $value ) {\r\nif ( isset( $post_navigation[ $key ]['post'] ) ) {\r\n$current_post = $value['post'];\r\n$post_id = isset( $value['post_id'] ) &amp;&amp; ! empty( $value['post_id'] ) ? $value['post_id'] : $current_post-&gt;ID;\r\n?&gt;\r\n&lt;a itemprop=\"url\"\r\nclass=\"qodef-e-navigation-item qodef--&lt;?php echo esc_attr( $key ); ?&gt;\"\r\nhref=\"&lt;?php echo esc_url( get_permalink( $post_id ) ); ?&gt;\"&gt;\r\n&lt;?php\r\nif ( ! empty( $value['label'] ) ) {\r\necho wp_kses( $value['label'], array( 'span' =&gt; array( 'class' =&gt; true ) ) );\r\n}\r\n?&gt;\r\n&lt;\/a&gt;\r\n&lt;?php } ?&gt;\r\n&lt;?php } ?&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This wraps up our explanation of the code responsible for displaying the content of our movie custom post type item.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><strong>Additional steps<\/strong><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>After creating the code<\/strong> for your custom template file, you should <strong>save it as a .php file and upload it to your server<\/strong> using FTP. You should place the file on your server into one of the four appropriate locations for custom template files. These are the active parent theme directory, active child theme directory, or a subdirectory within either of those two locations.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]As an additional piece of advice, you should <strong>take special care when naming the file<\/strong>. Avoid using any of the already reserved names (e.g. index, archive, page, single,\u2026) or names that contain an already reserved prefix (e.g. single-, archive-, page-,\u2026). We recommend <strong>naming the file the same as the template, so you can keep track of it easily<\/strong>. You can also upload the file into a newly-created subdirectory within your active theme to keep everything neatly ordered.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]However, if you opted to create <strong>template files that are slightly lower in the template hierarchy<\/strong> (i.e. single-{post-type}-{post-slug}.php or single-{post-type}.php), then there are <strong>only two locations where you can upload them<\/strong>. These are the directories of your parent or child theme, depending on which you are using.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you upload the template file, a new section named <em>Template<\/em> will appear in the backend of the movie single item. Generally speaking, this section doesn\u2019t need to be included using the <strong>supports<\/strong> property\u2014it will appear if there is at least one possible template to choose from. As such, <strong>to display the content that you added to your movie item<\/strong>, you will need to edit it <strong>and assign the template that you created earlier to the page or post. This is done from the <em>Template<\/em> section, located in the top right corner of the <em>movie<\/em> edit screen<\/strong>. Once you\u2019ve selected your template, <strong>press the <em>Update<\/em> button<\/strong> to update the movie item.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"619\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Choose-Template-and-Update.jpg\" class=\"attachment-full size-full\" alt=\"Choose Template and Update\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Choose-Template-and-Update.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Choose-Template-and-Update-300x192.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Choose-Template-and-Update-768x491.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Choose-Template-and-Update-620x396.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Don\u2019t forget, you will need to <strong>select the template for each new movie item that you create<\/strong>. And, if you created multiple templates, then you will be able to pick which one you want to use. After all that, you should <strong>examine the output<\/strong> of your custom post item (in our case, movie item) from the frontend.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]While selecting the proper template will ensure that all your content, including custom fields, meta boxes, and other custom properties, will be displayed, it doesn\u2019t mean you\u2019ll be happy with the stylization. Your content might only be partially stylized by the CSS properties that are currently found on your website. <strong>To fix any stylization issues, you will need to create additional CSS code.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]This CSS code needs to be created on a case-by-case basis as it relies on various factors, such as the existing HTML structure of the page and the CSS rules that are already present on the website. As such, <strong>you will need to create this CSS code on your own<\/strong>. But to help you, we will share <strong>the CSS we created to style our example<\/strong> for our article. It was created for our website specifically, so you shouldn\u2019t copy-paste it without modification.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">.qodef-e-inner {\r\ndisplay: flex;\r\nflex-direction: row;\r\nflex-wrap: wrap;\r\n}\r\n.qodef-e-media{\r\nmargin-bottom: 20px;\r\n}\r\n.qodef-e-media, .qodef-e-content {\r\ndisplay: flex;\r\nflex-direction: column;\r\nflex-basis: 100%;\r\n}\r\n@media screen and (min-width: 1025px) {\r\n.qodef-e-media, .qodef-e-content{\r\nflex: 1;\r\n}\r\n.qodef-featured-image{\r\npadding-right: 15px;\r\n}\r\n.qodef-e-content-inner {\r\npadding-left: 15px;\r\n}\r\n}\r\n.qodef-e-info-items h5 {\r\ncolor: #000;\r\nfont-weight: 600;\r\n}\r\n.qodef-e-genre-link:not(:last-of-type):after{\r\ncontent: ',';\r\n}\r\n.qodef-e-navigation {\r\ndisplay: flex;\r\njustify-content: space-between;\r\nmargin-top: 40px;\r\ncolor: #000;\r\nfont-weight: 600;\r\nfont-size: 18px;\r\n}<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After you create the CSS for your website, you need to know <strong>where to safely place it<\/strong>. For most WordPress users we suggest <strong>using the default WordPress location for storing CSS\u2014the Appearance &gt; Customize &gt; Additional CSS section<\/strong>. Make sure to properly comment on it, so that it stands out from any other CSS code you may have added before. However, more advanced WordPress users can put the CSS code they create into a separate file, upload it to the server, and enqueue it using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_style\/\" target=\"_blank\" rel=\"noopener\">wp_enqueue_style()<\/a> function. For more instructions on how to do that, you can take a look at our article on <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-enqueue-scripts-wordpress\/\">enqueueing custom scripts and stylesheets<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Finally, once you complete all the steps we previously described, it is time to examine the display of your custom post type item. You can see how our custom movie item turned out in the screenshot below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"640\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Result.jpg\" class=\"attachment-full size-full\" alt=\"Result\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Result.jpg 969w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Result-300x198.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Result-768x507.jpg 768w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2022\/09\/Result-620x409.jpg 620w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;78px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]Post types in WordPress allow you to publish various types of content and structure it differently so it stands out from the rest. However, WordPress webmasters often stick to the five default WordPress post types and find themselves constrained. This is often the case when the website being created has a niche, or highly specific, purpose or content. This makes creating custom post types the obvious solution.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this article, we discussed all the various steps that need to be taken to successfully make a custom post type. These include registering the custom post type and the taxonomy, or taxonomies, that are tied to it alongside the appropriate properties they possess. To do this, you can choose between a WordPress plugin and using code.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After adding content to our custom post type items, we also discussed what it takes to display these items on the website. While this process may be more challenging, we covered it in detail while touching on a deeper concept called the WordPress Template Hierarchy. Given all of this, we are confident you will be able to reproduce all these steps on your own and make a custom post type perfect for your website while gaining a deeper understanding of how WordPress works.<br \/>\n[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>If you were wondering what custom post types are in WordPress and how you can create them for your website, check out these useful tips and explanations. <\/p>\n","protected":false},"author":11229,"featured_media":8052,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[15,4,13],"class_list":["post-4004","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-plugins","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/4004","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/11229"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=4004"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/4004\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/8052"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=4004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=4004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=4004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}