{"id":137570,"date":"2015-03-05T07:00:00","date_gmt":"2015-03-05T12:00:00","guid":{"rendered":"http:\/\/premium.wpmudev.org\/blog\/?p=137570"},"modified":"2022-03-22T03:23:09","modified_gmt":"2022-03-22T03:23:09","slug":"creating-content-custom-post-types","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/creating-content-custom-post-types\/","title":{"rendered":"Creating Custom Content in WordPress: Custom Post Types"},"content":{"rendered":"<p>It&#8217;s pretty much universally agreed now that WordPress is more than just a blogging platform: It&#8217;s a <a href=\"https:\/\/wpmudev.com\/blog\/is-wordpress-an-actual-content-management-system-cms\/\" target=\"_blank\" rel=\"noopener\">Content Management System<\/a>.<\/p>\n<p>But in my view what makes it a powerful CMS is the ability to create custom content and display\u00a0that content in exactly the way you need to.<\/p>\n<p>In this, the first of two posts I&#8217;ll look at the three types of custom content in WordPress and show you how to create that content. I&#8217;ll cover:<\/p>\n<ul>\n<li>Custom post types<\/li>\n<li>Custom taxonomies<\/li>\n<li>Custom fields.<\/li>\n<\/ul>\n<p>In this first part of a two-part post series, I&#8217;ll introduce the concept of custom content in WordPress and demonstrate how to register and make use of a custom post type, as well as exploring how WordPress displays posts you create using that custom post type.<\/p>\n<p>Continue reading, or jump ahead using these links:<\/p>\n<ul>\n<li><a href=\"#kinds\">Understanding and Using Each Kind of Custom Content<\/a>\n<ul>\n<li><a href=\"#posts\">Custom Post Types<\/a><\/li>\n<li><a href=\"#taxonomies\">Custom Taxonomies<\/a><\/li>\n<li><a href=\"#fields\">Custom Fields<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#creating\">Creating a Custom Post Type<\/a>\n<ul>\n<li><a href=\"#coding\">Coding Your Post Type<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#displaying\">Displaying Your Post Type on the Front End<\/a>\n<ul>\n<li><a href=\"#permalinks\">Setting Permalinks to Link to Your Post Type\u2019s Pages<\/a><\/li>\n<li><a href=\"#menu\">Adding Your Post Type to the Navigation Menu<\/a><\/li>\n<li><a href=\"#template\">A Template For Your Post Type<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"kinds\">Understanding and Using\u00a0Each Kind of Custom Content<\/h2>\n<p>Before you start creating custom content, it&#8217;s useful to know exactly what each one does and what scenarios you might use them in. Let&#8217;s start with custom post types.<\/p>\n<h3 id=\"posts\">Custom Post Types<\/h3>\n<p>WordPress comes with a set of post types available to you by default. These are:<\/p>\n<ul>\n<li>Posts<\/li>\n<li>Pages<\/li>\n<li>Attachments<\/li>\n<li>Navigation menu items<\/li>\n<li>Revisions<\/li>\n<li>Links (if you&#8217;re using the blogroll feature)<\/li>\n<\/ul>\n<p>You can also create your own custom post types to store content that doesn&#8217;t fit into any of the above categories. Examples might include products in an e-commerce site or events in a listings site. If you&#8217;ve ever used a plugin to create a store, event listing, or any other kind of unique content, then chances are you&#8217;ve created custom post types without even knowing it.<\/p>\n<p>Plenty of our plugins use custom post types, for example:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/wpmudev\/marketpress\" target=\"_blank\">MarketPress<\/a> uses a custom post type for products.<\/li>\n<li><a href=\"https:\/\/github.com\/wpmudev\/coursepress\" target=\"_blank\">CoursePress Pro<\/a> uses custom post types for courses, instructors, and students.<\/li>\n<li><a href=\"https:\/\/github.com\/wpmudev\/support-system\" target=\"_blank\">Support System<\/a> uses custom post types for tickets and FAQs.<\/li>\n<\/ul>\n<p>There are plenty more examples, but this gives you an idea of the uses\u00a0of custom post types.<\/p>\n<p>It&#8217;s important to remember that custom post types are <strong>not<\/strong> posts. They don&#8217;t have any direct relation to posts and you should think of them separately. You can set up (or register) your custom post types to behave like posts or to behave like pages: it&#8217;s up to you. If they&#8217;re set up like posts you&#8217;ll be able to display archive pages of them while if they&#8217;re like pages they&#8217;ll be hierarchical. Most custom post types are configured to behave like posts but that doesn&#8217;t mean yours have to be.<\/p>\n<h3 id=\"taxonomies\">Custom Taxonomies<\/h3>\n<p>Like custom post types, custom taxonomies add to the taxonomies that are already provided with WordPress. These are:<\/p>\n<ul>\n<li>Categories<\/li>\n<li>Tags<\/li>\n<li>Post formats<\/li>\n<li>Link categories (which apply to links in the blogroll if you&#8217;re using it)<\/li>\n<\/ul>\n<p>You can also create your own custom taxonomies to organize your content more effectively. It&#8217;s important to remember that a custom taxonomy is <strong>not<\/strong> a category and has no relationship to categories: instead, &#8216;category&#8217; is just one of the taxonomies used by WordPress.<\/p>\n<p>Sometimes using the inbuilt categories will give you everything you need to sort your content, for example, if you need to introduce a hierarchical category structure. But sometimes this won&#8217;t be enough, especially if you want to be able to display posts using more than one taxonomy, or if you&#8217;re using a custom post type and want to use a separate taxonomy for it.<\/p>\n<p>Examples include:<\/p>\n<ul>\n<li>On an e-commerce site, product taxonomies &#8211; possibly multiple ones such as color, size and fabric for a clothing store.<\/li>\n<li>On an events listings site, taxonomies for event type, venues, and more.<\/li>\n<li>On a knowledgebase, taxonomies to sort data in a crosscutting way: for example if it&#8217;s a web development knowledgebase you might use taxonomies for programming languages, level of difficulty, and platforms.<\/li>\n<\/ul>\n<p>Again our plugins make use of custom taxonomies: for example in MarketPress there are product categories and product tags, which are separate from the categories and tags for blog posts; in CoursePress you have course categories, and in Support System, there are taxonomies for ticket types and FAQ categories.<\/p>\n<p>Before deciding if you need to register a custom taxonomy, you need to ask yourself if the existing category system will do what you need. If all you need is to be able to add a hierarchy to your categories, you can already do this.<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-right cgrid-col-span-1\">\n<div class=\"cgrid-col-wide-right\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-ratio-1-4 wp-image-137572\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/categories-177x205.png\" alt=\"categories\" width=\"177\" height=\"205\" \/><\/div>\n<\/div>\n<\/div>\n<p>So if I was developing a training site (for example) and wanted to use categories to sort posts by the skill or knowledge being taught, I might use hierarchical categories as shown in this screenshot. You can see here that I&#8217;ve got three top-level categories: management development, personal development, and technical skills, with everything else beneath these at the next level down.<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-right cgrid-col-span-1\">\n<div class=\"cgrid-col-wide-right\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-ratio-1-4 wp-image-137575\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/categories-and-taxonomy-177x315.png\" alt=\"categories-and-taxonomy\" width=\"177\" height=\"315\" \/><\/div>\n<\/div>\n<\/div>\n<p>But what if things got a bit more complicated? Let&#8217;s say I wanted to add a series of\u00a0posts on\u00a0communicating with your team.<\/p>\n<p>It would make things easier if I could separate out the fact that these posts\u00a0are for managers but also deal with communication skills. So maybe I could add a taxonomy for the audience, and use this to identify posts for managers instead of having management development as a category, I could create a new taxonomy for audiences. That way I can identify multiple topics and multiple audience groups for each post.<\/p>\n<p>I&#8217;ll show you how to create a taxonomy like this in the next part of this series: once you&#8217;ve done it, you&#8217;ll be able to choose from both categories and audience groups in the post editing screen, as shown in the screenshot.<\/p>\n<h3 id=\"fields\">Custom Fields<\/h3>\n<p>The third type of custom content is the <a href=\"https:\/\/wordpress.org\/support\/article\/custom-fields\/\" target=\"_blank\">custom\u00a0field<\/a>, also referred to as post metadata.<\/p>\n<p>A custom field consists of two elements that you can see and edit in the post editing screen: the <strong>key<\/strong> and the <strong>value<\/strong>. You can use the same key again and again for multiple posts, but each will have a unique value. WordPress also gives each custom field you create its own unique ID, which means that each custom field for each post is unique even if they have the same key and value.<\/p>\n<p>This is different from custom taxonomies: although you can choose from an existing key when creating a custom field, you can&#8217;t select from existing values you&#8217;ve used before. Generally, this means that taxonomies are better for sorting and categorizing data.<\/p>\n<p><em>Note: Some plugins will give you the option to choose the value of a custom\u00a0field from a dropdown\u00a0box, but this will use a\u00a0custom metabox created by the plugin in the post editing screen, instead of\u00a0the standard custom fields interface provided by WordPress.<\/em><\/p>\n<p>However, there are some cases in which using a custom field can be useful to sort data, for example, if you want to store numerical data. In an e-commerce site, you don&#8217;t want to create a taxonomy for every possible price: instead, you&#8217;d insert this in a custom field. You could then use this data to allow customers to identify products with a price below $20.00 for example, or to sort by price.<\/p>\n<p>You can also use custom fields to store non-numerical data, meaning you can store and display similar data between posts and display it separately from the body of the post. For example, in a jobs listing site, you might use custom fields to store the location, salary, and working hours for a vacancy.<\/p>\n<p>This is what the <a href=\"https:\/\/github.com\/wpmudev\/jobs-plus\" target=\"_blank\">Jobs &amp; Experts<\/a> plugin does: it uses a combination of custom\u00a0fields (referred to as\u00a0&#8216;Job Meta&#8217;) and taxonomies (&#8216;Category and Skill&#8217;) to sort data:<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-span-full\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-ratio-large wp-image-137578\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/jobsexperts-metadata-700x220.png\" alt=\"jobs&amp;experts-metadata\" width=\"700\" height=\"220\" \/><\/div>\n<\/div>\n<p>Once you&#8217;ve added this data, visitors to your jobs site will be able to sort jobs by\u00a0budget, display only those jobs which are still open and see the contact email and completion date for each job displayed prominently. A taxonomy is used for skills so that archive pages for each of these can be displayed.<\/p>\n<p>You&#8217;ll learn how to create your own custom fields in the next part of this series: in this post, we&#8217;ll move on to creating\u00a0custom post types.<\/p>\n<h2 id=\"creating\">Creating a Custom Post Type<\/h2>\n<p>Once you&#8217;ve identified that you need a custom post type, there are two ways to go about it:\u00a0coding it yourself or using a plugin. I&#8217;ll demonstrate the code necessary to register a custom post type in a theme or plugin shortly but first let&#8217;s look at some of the plugins you can use:<\/p>\n<ul>\n<li>Our own <a href=\"https:\/\/github.com\/wpmudev\/custompress\" target=\"_blank\">CustomPress<\/a> provides you with an interface for creating custom post types, taxonomies, and custom fields and is very user-friendly. If you want to create many types of custom content, this will save you installing more than one plugin.<\/li>\n<li>The <a href=\"https:\/\/wordpress.org\/plugins\/custom-post-type-ui\/\" target=\"_blank\">Custom Post Type UI<\/a> plugin is the most popular free plugin for adding custom post types on the plugin repository. It lets you add custom post types and taxonomies, but not custom fields. The interface isn&#8217;t quite as user-friendly as with CustomPress, with more technical terminology for you to get your head around, but it does the job.<\/li>\n<\/ul>\n<p>You can read more about plugins to help you create custom content in our review of\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/top-wordpress-cms-plugins-reviewed\/\" target=\"_blank\">the best CMS plugins<\/a>.<\/p>\n<p>But if you&#8217;re comfortable with coding your own, here&#8217;s how you go about registering a custom post type.<\/p>\n<h3 id=\"coding\">Coding Your Post Type<\/h3>\n<p>WordPress provides a function called <code><a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/register_post_type\" target=\"_blank\">register_post_type()<\/a><\/code> which you use to create your custom post type. You add the function to your theme&#8217;s functions file or (even better) to a plugin you create especially, and then fire it via the <code>init<\/code> hook in WordPress.<\/p>\n<p><em>Note: It&#8217;s better to register\u00a0your custom post type in a plugin rather than your theme because then if you change your theme in the future, you won&#8217;t lose your custom post type.<\/em><\/p>\n<p>To follow this technique you&#8217;ll need access to your WordPress files and a code editor. I recommend trying this out in a development site and not on your live site!<\/p>\n<p>Start by creating a new empty file called <code>post-types.php<\/code> and save it to the <code>plugins<\/code> folder in your <code>wp-content<\/code> directory.<\/p>\n<p>Now add the following code to your file:<\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"gist\" data-gist=\"83e83351818c22241a3904d4d1104466\" data-gist-file=\"1502 cpt plugin opening\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/83e83351818c22241a3904d4d1104466.js?file=1502+cpt+plugin+opening\">Loading gist 83e83351818c22241a3904d4d1104466<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div><\/span><\/p>\n<p>This opens the plugin file and tells WordPress that it&#8217;s a plugin.\u00a0It also provides a title and a description\u00a0which will help you identify the plugin when you activate it in your site.<\/p>\n<p>Next, below the line that reads <code>*\/<\/code> and above the closing <code>?&gt;<\/code> line, add these lines:<\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"gist\" data-gist=\"4a58db85ac366f3b4c8ece6c6bf1e30e\" data-gist-file=\"gistfile one\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/4a58db85ac366f3b4c8ece6c6bf1e30e.js?file=gistfile+one\">Loading gist 4a58db85ac366f3b4c8ece6c6bf1e30e<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div><\/span><\/p>\n<p>This creates a function which will hold the code to register your post type and then attaches it to the <code>init<\/code> hook using the <code><a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/add_action\" target=\"_blank\">add_action()<\/a><\/code> function. This makes sure that WordPress runs your function at the right time.<\/p>\n<p>Now you need to add the code for your custom post type inside the curly braces:<\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"gist\" data-gist=\"dca43d92140e726dfecb516f3fcf51bc\" data-gist-file=\"gistfile one\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/dca43d92140e726dfecb516f3fcf51bc.js?file=gistfile+one\">Loading gist dca43d92140e726dfecb516f3fcf51bc<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div><\/span><\/p>\n<p>Let&#8217;s take a close look at what this code does. The first section tells WordPress what labels you want to use for your post type. These will replace the default labels which are &#8216;Posts&#8217;, &#8216;Add Post&#8217; etc. Next, you call the <a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/register_post_type\" target=\"_blank\"><code>register_post_type()<\/code><\/a>\u00a0function, which has the following parameters:<\/p>\n<ul>\n<li><strong><code>title<\/code>:<\/strong> your function won&#8217;t work without this.<\/li>\n<li><strong><code>labels<\/code>:<\/strong> the labels you already specified.<\/li>\n<li><strong><code>has_archive<\/code><\/strong>: by setting this to <code>true<\/code> you&#8217;re telling WordPress that it&#8217;s possible to show archive pages for this post type.<\/li>\n<li><strong><code>public<\/code><\/strong>: set this to true to make sure people can see a page\u00a0on your website for each product.<\/li>\n<li><strong><code>supports<\/code><\/strong>: the elements of the WordPress admin that the custom post type supports.<\/li>\n<li><strong><code>taxonomies<\/code><\/strong>: an array of the taxonomies you want to use with the post type. I&#8217;ve used the inbuilt categories and tags, although you might want to leave this blank and register a custom taxonomy for your post type later on.<\/li>\n<li><strong><code>exclude_from_search<\/code><\/strong>: set this to false to make sure your products are included in search results.<\/li>\n<li><strong><code>capability_type<\/code><\/strong>:\u00a0this is set as <code>post<\/code> as our products will behave like posts and not pages.<\/li>\n<li><strong><code>rewrite<\/code><\/strong>: this tells WordPress what the slug is for the post type archive, which is the text to use\u00a0after your domain name\u00a0for its URL. By setting this to <code>products<\/code>, the URL for the products page will be <code>http:\/\/mysite.com\/products\/<\/code><\/li>\n<\/ul>\n<p>Now save your file. The entire plugin&#8217;s code will look like this:<\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"gist\" data-gist=\"0b5f93b724c6f1ccd6462d8c1bb7264e\" data-gist-file=\"filename\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/0b5f93b724c6f1ccd6462d8c1bb7264e.js?file=filename\">Loading gist 0b5f93b724c6f1ccd6462d8c1bb7264e<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div><\/span><\/p>\n<p>For your post type to\u00a0work you&#8217;ll need to activate your new plugin. Go to the Plugins page in your site admin and find your new plugin:<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-span-full\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-ratio-large wp-image-137583\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/activate-cpt-plugin-700x77.png\" alt=\"activate-cpt-plugin\" width=\"700\" height=\"77\" \/><\/div>\n<\/div>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-right cgrid-col-span-2\">\n<div class=\"cgrid-col-wide-right\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-137584\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/admin-menu-with-new-post-type.png\" alt=\"admin-menu-with-new-post-type\" width=\"174\" height=\"180\" \/><\/div>\n<\/div>\n<\/div>\n<p>Click the <strong>Activate<\/strong> link to activate it. You&#8217;ll now see an extra post type in your admin menu:<\/p>\n<div class=\"image-grid cgrid-row\"><\/div>\n<p>You can click on the <strong>Products<\/strong>\u00a0link and start adding products to your site in just the same way as you would posts.<\/p>\n<h2 id=\"displaying\">Displaying Your Post Type on the Front End<\/h2>\n<p>Once you&#8217;ve added some products, you&#8217;ll need to be able to display\u00a0these on the front end of your site.<\/p>\n<h3 id=\"permalinks\">Setting\u00a0Permalinks to Link to Your Post Type&#8217;s Pages<\/h3>\n<p>First, you need to refresh the permalinks on your site so that WordPress will use the correct links to display products or product archives:<\/p>\n<ol>\n<li>In the WordPress admin, go to <strong>Settings -&gt; Permalinks<\/strong>.<\/li>\n<li>Make sure the &#8216;post name&#8217; option is selected.<\/li>\n<li>Click the <strong>Save Changes<\/strong> button.<\/li>\n<\/ol>\n<p><em>Note: You need to do this even if you&#8217;ve already configured permalinks, as WordPress needs to refresh these settings for the new set of links to your products.<\/em><\/p>\n<h3 id=\"menu\">Adding Your Post Type to the Navigation Menu<\/h3>\n<p>If you want to add products to your navigation menu, you can. Go to <strong>Appearance -&gt; Menus<\/strong>, and you&#8217;ll see that Products are displayed on the left. Simply drag any products onto your menu to include them.<\/p>\n<p>Adding your product archive is a bit trickier, and for this, you&#8217;ll need to add a custom link to the menu.<\/p>\n<ol>\n<li>Still on the Menus screen, click on the <strong>Links<\/strong> box to the left.<\/li>\n<li>In the <strong>URL<\/strong>\u00a0field, type <code>http:\/\/mysite.com\/products\/<\/code>, replacing <code>mysite.com<\/code>\u00a0with your own\u00a0domain.<\/li>\n<li>In the Link text field, type <strong>Products<\/strong>.<\/li>\n<li>Click the <strong>Add to Menu<\/strong> button.<\/li>\n<li>Once the link has been added to the menu, move it to the right place, and save the menu.<\/li>\n<li>Save your changes by clicking <strong>Save Menu<\/strong>. <strong>Don&#8217;t miss this step!<\/strong><\/li>\n<\/ol>\n<p>Now if you visit your site&#8217;s front end and click on that menu link, you&#8217;ll be taken to your product archive page. Here&#8217;s mine:<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-span-full\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-ratio-large wp-image-137588\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/02\/prodyct-archive-page-700x419.png\" alt=\"product-archive-page\" width=\"700\" height=\"419\" \/><\/div>\n<\/div>\n<p>So now you have a page to display all of your products. But what if you want to customize the way you display them?<\/p>\n<h3 id=\"template\">A Template For Your Post Type<\/h3>\n<p>WordPress uses something called the <a href=\"http:\/\/codex.wordpress.org\/Template_Hierarchy\" target=\"_blank\">template hierarchy<\/a> to identify which template file in your theme it should use to display a given content type. It&#8217;s beyond the scope of this post to describe how the template hierarchy works in detail, but\u00a0it helps to know how WordPress displays your new post type.<\/p>\n<p>When WordPress displays a single product, it will look for each of these files in order in your theme:<\/p>\n<ol>\n<li>A file for displaying single products, called <code>single-product.php<\/code>.<\/li>\n<li>A file for deploying all single posts of any post type, called <code>single.php<\/code>.<\/li>\n<li>The generic file for deploying all kinds of content, called <code>index.php<\/code>.<\/li>\n<\/ol>\n<p>When WordPress displays a product archive, it will work through these template files:<\/p>\n<ol>\n<li>A file for displaying the product archive, called <code>archive-product.php<\/code>.<\/li>\n<li>A generic archive template, called <code>archive.php<\/code>.<\/li>\n<li>The default template, <code>index.php<\/code>.<\/li>\n<\/ol>\n<p>WordPress will work through this hierarchy and use the template file it comes across first. So if you want to create a custom template for your products, a good place to start is by copying the <code>single.php<\/code> file, saving it as <code>single-product.php<\/code> and editing that.<\/p>\n<p>However, if you don&#8217;t want to create template files, WordPress will happily use the files already present in your theme, which is what it&#8217;s done for me with the twenty fifteen theme&#8217;s <code>archive.php<\/code> and <code>single.php<\/code> files.<\/p>\n<h2>Summary<\/h2>\n<p>Being able to create custom content makes WordPress very powerful: you can use it to add and display a range of flexible content types in whichever way you need to.<\/p>\n<p>In this post, you&#8217;ve learned about the three types of custom content, what they are, and when to use each of them. You&#8217;ve also learned how to create a custom post type and display it on your site.<\/p>\n<p>In the next part, you&#8217;ll learn <a title=\"Creating Custom Content in WordPress: Taxonomies and Fields\" href=\"https:\/\/wpmudev.com\/blog\/creating-content-taxonomies-and-fields\/\" target=\"_blank\">how to create custom taxonomies and custom\u00a0fields<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What makes WordPress a powerful CMS is the ability to create custom content and display that content in exactly the way you need to. In this first part of a two-part series, we look custom post types, custom taxonomies, and custom fields.<\/p>\n","protected":false},"author":4,"featured_media":138500,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[557,263],"tags":[390,1041,131],"tutorials_categories":[],"class_list":["post-137570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","category-tutorials","tag-code","tag-custom-post-types","tag-developers"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/137570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=137570"}],"version-history":[{"count":10,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/137570\/revisions"}],"predecessor-version":[{"id":207633,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/137570\/revisions\/207633"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/138500"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=137570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=137570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=137570"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=137570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}