WordPress development

Custom post type or types of custom "post" (Part I)

custom post type; what they are, what they should be used for and how to create them

Although this headline looks like a leaflet for a medicine, in this post and in the next ones I am going to tell you in a simple way what a Custom Post Type is, what they are for or what they should be used for and, of course, how to create them in a simple way. or in a more advanced way without any type of plugin, we are going to create it from scratch in the theme, but in order not to lose the content if we change the theme, we will create a plugin with all the programming that we create.

Do you want to get into the subject? so let's start...

In this first part I am going to explain what a Custom Post Type is, the types that already exist in WordPress and the use of each one.

What is a Custom Post Type in WordPress?

For me, a custom post type is a WordPress expansion to better manage the content that we want to publish and the way to show it to the user.

I must confess that I love them and it is my favorite way of create additional content that does not fit a page or a post.

To explain what a CPT is (abbreviated form that I am going to refer to in this entry for the Custom Post Type) First we have to know what is an entry or post and what is a page.

One input is what we call dynamic content,

  • Where is written or should be written regularly
  • Where content is categorized by adding a category
  • The content is tagged
  • Has a creation or publication date
  • has an author
  • The entries do not have a hierarchy, that is, there are no parent entries (or superiors) to the entry, they are all in the same line of importance.

I will explain the hierarchies in the following posts, so don't miss it

A page, I understand it as a static content

  • They are written once and rarely changed.
  • Pages have no categories
  • Pages are not tagged
  • The publication date is not shown (although they have it)
  • The author is not shown (although it does have an author)
  • But if they have a hierarchy, there are superior pages or parent pages if you want to rank the pages

There are other types of predefined "post" in WordPress although we do not see it as pages or posts.

Normally, the CPTs that we create are stored in the database table "wp_post" (for security I hope that this table, in your database, is not called like that, and if so read this entry on security and immediately change your database prefix)

Let's do a search in the database and we will see what types of posts exist by default, as soon as WordPress is installed.

In alphabetical order we find the following type of post:

  • Attachment are the attachments to a post or all those images and documents that we upload to the media and that we associate. (cpt = "attachment")
  • Custom CSS are post types that are created by making custom CSS Custom CSS (cpt = "custom_css")
  • Customize Changeset are types of posts that are created when using the WordPress customizer from the frontend (cpt= “customize_changeset”) Both those that are kept when saving changes and those that have remained in auto-save are saved (they expire after a week ). So if we change the subject, these changes remain.WordPress Customizer - WordPress Customizer
  • Navigation Menu or the different navigation menus that you can create from the WordPress admin (cpt = “nav_menu_item”)
  • Entries, which I have already described above (cpt = "post")
  • Pages, which I have also described above (cpt = "page")
  • Revision which are the revisions that are automatically created as auto-save when we are writing an entry or page (cpt = "revision")

Apart from these post types that come by default in WordPress, many plugins create post types to include the content within your website, for example Contact Form 7 create a type of post that are the different contact forms.

Contact Form as a Custom Post Type in WordPress

And now …. Would you know how to identify a CPT?

Write us a comment if it has not been clear to you that it is a Custom Post Type.

In future posts you will have more information on why to use them and how to create them.

If you need a site made with custom WordPress, made exclusively for you or for your client, do not hesitate to contact us, for this or any other configuration ask us for a quoteyou will be pleasantly surprised 

¡Subscribe to our newsletter and receive our offers, news and discounts directly to your email!