{"id":1084,"date":"2018-01-31T11:26:40","date_gmt":"2018-01-31T11:26:40","guid":{"rendered":"https:\/\/firstsiteguide.com\/create-custom-post-types\/"},"modified":"2023-10-04T09:28:26","modified_gmt":"2023-10-04T09:28:26","slug":"wordpress-custom-post-types","status":"publish","type":"post","link":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/","title":{"rendered":"How to Create Custom Post Types in WordPress","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"

Before we actually show you how to create your own custom post type which you’ll be proudly using on your new WordPress powered blog<\/a>, let’s see what a custom post type actually is.<\/p>\n\n\n\n

A post type is simply a set of rules which are used to describe the way content is presented in your article. Each post type has its own parameters which define it so you can tell a difference between a post, page, archive, revision or a navigation menu<\/a>. But as you will see, if you start writing articles as your posts, everything you write will have the same structure. That\u2019s because you will use the same template for the post. But that is completely OK if you write a blog where one post type is enough to handle your articles.<\/p>\n\n\n\n

Through the not so long history, WordPress has evolved tremendously and it has definitely outgrown its role as a blog platform<\/a>. It has become one of the most used and appreciated content management systems in the world. Allowing people to create custom post types is one of the main reasons for that.<\/p>\n\n\n\n

Let’s see what a custom post type can do for you in a simple example. Imagine you are running a gaming website. You want to publish news on a regular basis, there are numerous trailers published every day which you can share with your audience, your authors play new games and write reviews, you want to publish screenshots from your latest online match, etc.<\/p>\n\n\n\n

As you can already guess, there are several content types you would need in this case and if you continue on using regular posts, all of the content will look the same and it will make it harder for you and for your visitors to find a difference between a video article and a review. Yes, you want a custom post type to make everything look more organized.<\/p>\n\n\n\n

Stay with that picture just for a few more seconds. If you create a custom post type, your news could have a special area where you can place a link to the source. Your game review post type could have a rating the author gave to a certain game including a star-based system, and you can apply different styling for, let’s say, the subtitle of your review. Your trailers post type would accentuate a video and let people enjoy it from a lightbox instead of viewing it in a post. We can go on forever, but you get the point, right?<\/p>\n\n\n\n

Create a Custom Post Type<\/h2>\n\n\n\n

OK, we know you are getting bored with our talk \u2013 you are here to learn how to create a custom post so let’s start. Stretch your muscles, take a deep breath and when you are ready, let’s start. If you’re interested in digging deeper into WordPress<\/a> and the code, skip to the plugin that will help you<\/a>.<\/p>\n\n\n\n

    \n
  1. Open functions.php file and paste the following code.<\/li>\n<\/ol>\n\n\n\n

    Make sure the code is placed before the closing PHP tag (?>) or it won’t work.<\/p>\n\n\n

    \n \n\n
    \/\/ Creates Game Reviews Custom Post Type
    function game_reviews_init() {
    $args = array(
    'label' => 'Game Reviews',
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array('slug' => 'game-reviews'),
    'query_var' => true,
    'menu_icon' => 'dashicons-video-alt',
    'supports' => array(
    'title',
    'editor',
    'excerpt',
    'trackbacks',
    'custom-fields',
    'comments',
    'revisions',
    'thumbnail',
    'author',
    'page-attributes',)
    );
    register_post_type( 'game-reviews', $args );
    }
    add_action( 'init', 'game_reviews_init' );<\/pre>\n\n<\/div>\n\n\n
    <\/pre>\n\n\n\n
      \n
    1. Save changes<\/li>\n<\/ol>\n\n\n\n

      If you take a look at your admin area in WordPress<\/a>, you will notice there is a new item “Game Reviews” available on the menu. So far, it will look like any other post but you will still not be able to see these posts online. You have a few more steps to follow through in order to make the most out of this custom post type.<\/p>\n\n\n

      \n \n\n

      Be sure to set up your permalinks before you try your new post or you’ll end up with an error.<\/p>\n\n<\/div>\n\n\n

      Create a template for your new custom post type:<\/h3>\n\n\n\n
        \n
      1. Open your theme’s folder<\/li>\n\n\n\n
      2. Create a new file and name it something like game-review-template.php<\/li>\n\n\n\n
      3. Open the file and paste the following:<\/li>\n<\/ol>\n\n\n
        \n \n\n
        <?php
        \/**
        * Template Name: Game Reviews
        **\/
        ?><\/pre>\n\n<\/div>\n\n\n
        <\/pre>\n\n\n\n
          \n
        1. Open page.php file which is located in your theme’s folder<\/li>\n\n\n\n
        2. Copy and paste the code into you game-review-template.php<\/li>\n\n\n\n
        3. Find a piece of code which is the same, or similar to this (might depend on your theme):<\/li>\n<\/ol>\n\n\n
          \n \n\n
          <?php endif; ?>
          <?php endwhile; ?><\/pre>\n\n<\/div>\n\n\n
          <\/pre>\n\n\n\n

          When you have located this part, let’s modify it so you can show your custom post type on a new page. You should add the $query<\/em> line above your loop and then modify the loop itself. When you modify the code, it should look like this:<\/p>\n\n\n

          \n \n\n
          <?php\n $query = new WP_Query( array('post_type' \n=> 'game-reviews','posts_per_page' => 5 ) );\n while ( $query->have_posts() ) : $query->the_post(); \n?>\n\/\/ Your code e.g. \"the_content();\"<\/pre>\n\n<\/div>\n\n\n
          <\/pre>\n\n\n\n
            \n
          1. Save changes<\/li>\n\n\n\n
          2. Go to Pages -> Add new<\/li>\n\n\n\n
          3. Create a page with the name “Game Reviews”<\/li>\n\n\n\n
          4. On the right side, under the “Page Attributes” tab you should find “Template”<\/li>\n<\/ol>\n\n\n
            \n
            \"Custom<\/figure><\/div>\n\n\n

            <\/p>\n\n\n\n

            Choose a template you have created in one of the previous steps and assign it to the page.<\/p>\n\n\n\n

              \n
            1. Save changes<\/li>\n\n\n\n
            2. That’s it. You should try everything and create a new Game Review post. Once you open your Game Review page, you should be able to see your news post types lined up chronologically just like your normal post would be.<\/li>\n<\/ol>\n\n\n\n

              And this is just the beginning. You have created the custom post type, but now you should modify it the way you like it and add the code which you need.<\/p>\n\n\n\n

              Create custom post types with plugins<\/h2>\n\n\n\n

              When you start creating your own post types to expand your WordPress, there are two ways to go. We already showed you one – how to manually create a custom post type<\/a>. By following several steps, you can create a custom post type but it might take much of your time if you are a WordPress beginner<\/a> and not used to dealing with the code. But you don\u2019t have to mess around with the code – if you need a simpler and quicker solution, you can create numberless custom post types by using one of the plugins.<\/p>\n\n\n\n

              In this part of the tutorial, we\u2019re about to show you one of the best plugins which will create those custom post types for you. You won\u2019t have to code or even copy\/paste the code. Simply install the plugin, write in the name of your new post type and set it up through GUI.<\/p>\n\n\n\n

              Custom Post Type UI<\/h3>\n\n\n\n

              PRICE: <\/strong>Free<\/a><\/p>\n\n\n

              \n
              \"Custom<\/figure><\/div>\n\n\n

              <\/p>\n\n\n\n


              If you only need to register a custom post type, this plugin will do a good job. After you install it, you\u2019ll be able to create custom post types and taxonomies. Simply go to a newly created menu, add a new custom post type, and write the name and description of your new post type. It is easy as that but you will have to notice that this plugin won\u2019t handle displaying your new post type<\/strong>. Once you register the new post type, it is still up to you how to display it. We suggest that you check out how to do that or go with some other plugin which can also display your posts.<\/p>\n\n\n

              \n
              Read more:<\/div>\n
              \n \n Guide on WordPress Custom Post Types <\/a>\n <\/div>\n<\/div>\n\n\n

              Conclusion<\/h2>\n\n\n\n

              Custom Post Types are one of the greatest WordPress features even today. By simply modifying a few lines of code, or using a plugin, you can generate a post type that will be unique to your site. The truth is that it might be a little bit harder for a beginner to complete everything for the first time, but if you stick with this tutorial, you should not have any problems.<\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"

              Before we actually show you how to create your own custom post type which you’ll be proudly using on your new WordPress powered blog, let’s see what a custom post type actually is. A post type is simply a set of rules which are used to describe the way content is presented in your article. […]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":1085,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[7],"tags":[],"acf":[],"yoast_head":"\nCreate Custom Post Types in WordPress Manually (or Plugins)<\/title>\n<meta name=\"description\" content=\"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Custom Post Types in WordPress Manually (or Plugins)\" \/>\n<meta property=\"og:description\" content=\"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\" \/>\n<meta property=\"og:site_name\" content=\"FirstSiteGuide\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/firstsiteguide\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-31T11:26:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-04T09:28:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/custom-post-types-plugins-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Artem Minaev\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@firstsiteguide\" \/>\n<meta name=\"twitter:site\" content=\"@firstsiteguide\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Artem Minaev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\"},\"author\":{\"name\":\"Artem Minaev\",\"@id\":\"https:\/\/firstsiteguide.com\/#\/schema\/person\/f50d1a14c8700f98e503501648a92296\"},\"headline\":\"How to Create Custom Post Types in WordPress\",\"datePublished\":\"2018-01-31T11:26:40+00:00\",\"dateModified\":\"2023-10-04T09:28:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\"},\"wordCount\":1201,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/firstsiteguide.com\/#organization\"},\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\",\"url\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\",\"name\":\"Create Custom Post Types in WordPress Manually (or Plugins)\",\"isPartOf\":{\"@id\":\"https:\/\/firstsiteguide.com\/#website\"},\"datePublished\":\"2018-01-31T11:26:40+00:00\",\"dateModified\":\"2023-10-04T09:28:26+00:00\",\"description\":\"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.\",\"breadcrumb\":{\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/firstsiteguide.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Custom Post Types in WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/firstsiteguide.com\/#website\",\"url\":\"https:\/\/firstsiteguide.com\/\",\"name\":\"FirstSiteGuide\",\"description\":\"Online Business Advice\",\"publisher\":{\"@id\":\"https:\/\/firstsiteguide.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/firstsiteguide.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/firstsiteguide.com\/#organization\",\"name\":\"FirstSiteGuide\",\"url\":\"https:\/\/firstsiteguide.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/firstsiteguide.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/fsg-logo-green.svg\",\"contentUrl\":\"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/fsg-logo-green.svg\",\"width\":73,\"height\":70,\"caption\":\"FirstSiteGuide\"},\"image\":{\"@id\":\"https:\/\/firstsiteguide.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/firstsiteguide\",\"https:\/\/twitter.com\/firstsiteguide\",\"https:\/\/www.instagram.com\/firstsiteguide\/\",\"https:\/\/www.linkedin.com\/company\/firstsiteguide\/\",\"https:\/\/www.pinterest.com\/firstsiteguide\/\",\"https:\/\/www.youtube.com\/firstsiteguide\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/firstsiteguide.com\/#\/schema\/person\/f50d1a14c8700f98e503501648a92296\",\"name\":\"Artem Minaev\",\"sameAs\":[\"http:\/\/vps66354.inmotionhosting.com\/~firsts43\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Custom Post Types in WordPress Manually (or Plugins)","description":"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/","og_locale":"en_US","og_type":"article","og_title":"Create Custom Post Types in WordPress Manually (or Plugins)","og_description":"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.","og_url":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/","og_site_name":"FirstSiteGuide","article_publisher":"https:\/\/www.facebook.com\/firstsiteguide","article_published_time":"2018-01-31T11:26:40+00:00","article_modified_time":"2023-10-04T09:28:26+00:00","og_image":[{"width":640,"height":400,"url":"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/custom-post-types-plugins-1.jpg","type":"image\/jpeg"}],"author":"Artem Minaev","twitter_card":"summary_large_image","twitter_creator":"@firstsiteguide","twitter_site":"@firstsiteguide","twitter_misc":{"Written by":"Artem Minaev","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#article","isPartOf":{"@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/"},"author":{"name":"Artem Minaev","@id":"https:\/\/firstsiteguide.com\/#\/schema\/person\/f50d1a14c8700f98e503501648a92296"},"headline":"How to Create Custom Post Types in WordPress","datePublished":"2018-01-31T11:26:40+00:00","dateModified":"2023-10-04T09:28:26+00:00","mainEntityOfPage":{"@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/"},"wordCount":1201,"commentCount":0,"publisher":{"@id":"https:\/\/firstsiteguide.com\/#organization"},"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/","url":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/","name":"Create Custom Post Types in WordPress Manually (or Plugins)","isPartOf":{"@id":"https:\/\/firstsiteguide.com\/#website"},"datePublished":"2018-01-31T11:26:40+00:00","dateModified":"2023-10-04T09:28:26+00:00","description":"Custom Post Types can help you organize your WordPress content more easily. Learn how to create them on your own.","breadcrumb":{"@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/firstsiteguide.com\/wordpress-custom-post-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/firstsiteguide.com\/"},{"@type":"ListItem","position":2,"name":"How to Create Custom Post Types in WordPress"}]},{"@type":"WebSite","@id":"https:\/\/firstsiteguide.com\/#website","url":"https:\/\/firstsiteguide.com\/","name":"FirstSiteGuide","description":"Online Business Advice","publisher":{"@id":"https:\/\/firstsiteguide.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/firstsiteguide.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/firstsiteguide.com\/#organization","name":"FirstSiteGuide","url":"https:\/\/firstsiteguide.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/firstsiteguide.com\/#\/schema\/logo\/image\/","url":"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/fsg-logo-green.svg","contentUrl":"https:\/\/firstsiteguide.com\/wp-content\/uploads\/2020\/11\/fsg-logo-green.svg","width":73,"height":70,"caption":"FirstSiteGuide"},"image":{"@id":"https:\/\/firstsiteguide.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/firstsiteguide","https:\/\/twitter.com\/firstsiteguide","https:\/\/www.instagram.com\/firstsiteguide\/","https:\/\/www.linkedin.com\/company\/firstsiteguide\/","https:\/\/www.pinterest.com\/firstsiteguide\/","https:\/\/www.youtube.com\/firstsiteguide"]},{"@type":"Person","@id":"https:\/\/firstsiteguide.com\/#\/schema\/person\/f50d1a14c8700f98e503501648a92296","name":"Artem Minaev","sameAs":["http:\/\/vps66354.inmotionhosting.com\/~firsts43"]}]}},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/posts\/1084"}],"collection":[{"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":20,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":14735,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/posts\/1084\/revisions\/14735"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/media\/1085"}],"wp:attachment":[{"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/firstsiteguide.com\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}