How To Register A Custom Post Type In Wordpress In A Plugin
WordPress custom postal service types are powerful features. They're what elevates WordPress from a humble blogging tool to a content direction system, and give you the earth-shaking flexibility yous need to create a bespoke website.
Simply they can cause defoliation: what are WordPress custom postal service types exactly? How do they differ from standard posts and pages? How do you create them? And once you have created a custom mail blazon, how practice you add to it, display information technology on your site, and how is it stored past WordPress?
In this article, I'll show you exactly how WordPress custom postal service types work. I'll compare them to the post types you might be more than familiar with, teach you how to create them, and show you lot how to use theme template files to display them in your site.
Specifically, I'll cover:
So let's become started!
What Are Custom Mail Types in WordPress?
It's probably easier to explain what custom post types in WordPress are by explaining a broader concept: postal service types.
Postal service types are ways of categorizing different types of content in WordPress. I'm assuming you're already familiar with the two most mutual post types: posts and pages. Only what you might not know is that WordPress also comes bundled with a few other post types.
Postal service Types That Come Bundled with WordPress
WordPress comes with seven post types:
- Posts
- Pages
- Attachments
- Revisions
- Navigation Menus
- Custom CSS
- Changesets
Chances are yous've never heard of changesets and you may use custom CSS in your site, but it hasn't occurred to you that these might be mail types.
For most WordPress users and developers, the only post types you need to concern yourself with are the first five: posts, pages, attachments, revisions, and navigation menus.
Let's have a wait at each of those mail types so we can empathise more about them.
WordPress Post Types: Posts
The "post" is the mail type you lot'll use the about in WordPress. Posts are dynamic content: designed to exist updated regularly. You can add together categories and tags to them, pregnant that they'll be displayed in multiple annal pages, and they'll besides show up on your habitation page or your weblog page likewise. Normally, your posts will make upward the majority of the content on your site.
Note: In WordPress, "mail service" means two things. In the database, a mail service is a post of any post type, then it will include pages, attachments, and everything else. When most of u.s. talk well-nigh posts, nosotros mean the posts in our blog, which belong to the "post" mail type.
WordPress Post Types: Pages
If y'all already accept a WordPress site, pages are the other content type you'll be familiar with. They're static content, designed to stick around longer than posts and to provide information on the kinds of things that don't change so frequently. Good examples are your contact details or the "about united states" page on a business website.
Pages can't take categories or tags and aren't designed to be displayed on annal pages. Instead, visitors volition access them via your navigation carte du jour.
Note: In internet lingo, a page can mean any kind of folio on your website. When the net kickoff developed, it consisted solely of static content that had to be coded directly by writing HTML. So a "webpage" tin can be any kind of page on your site, including a static page in WordPress terms, an archive folio, or a post. In this article, when I refer to pages, I'll mean the page in WordPress terms, i.east. a static page. Sometimes I'll refer to archive pages, but they aren't pages in the sense that you create a page to shop them. WordPress does that for you lot.
WordPress Mail Types: Attachments
An attachment is a media detail that's been uploaded to your site. In the WordPress database, this isn't the media file itself, but the information relating to it. So, each zipper will take a unique ID and metadata such equally its title, description, ALT text, and more.
Each zipper as well has its own attachment page with a unique URL. You tin can find the URL for this via the media editing screen for that attachment:

Attachments tin exist any kind of upload: images, videos, pdf files, and more. Y'all tin can access and edit them via the Mediaitem in the WordPress admin menu, or you can upload them directly to posts/pages when you're editing them. Any zipper you upload to a post will then be available to edit and view via the Mediamenu.
WordPress Postal service Types: Revisions
Now we're getting on to the slightly more obscure post types.
Every time you lot salve a new version of a mail service, page, attachment, or indeed any custom mail type, WordPress volition create a revision to reverberate that version of the post (or page, etc.).
You can view the revisions to any post or folio in your site by going to its relevant editing screen and opening the Certificatetab on the correct-paw side. Here you will encounter a notification telling you how many revisions this post has. Below you lot tin can come across a screenshot of a post I'm editing that currently has v revisions.

If you aren't using the Gutenberg editor, you tin can access revisions by scrolling to the bottom of the editing screen and finding a listing of them hither:

If you click on the Revisionsbox, y'all'll be taken to a screen displaying your latest two versions of your post. From here you can review the revisions and revert to an earlier version of the post.
WordPress will create a lot of revisions for your site over fourth dimension, pregnant that the database will be full of them (here'southward Kinsta's guide on how to handle revisions for faster operation)! Just revisions are a mail type just like whatever other, and they're stored in the same way – more of which shortly.
WordPress Post Types: Navigation Menus
Navigation menus, or more precisely, the items in your navigation menus, are also a post blazon.
Each detail in your navigation menu is stored as an item in the database. Thank you to its metadata, WordPress knows this is a navigation menu item, exactly where in the navigation bill of fare it should appear, and where it links to.
You can't edit navigation menu items the same fashion you lot would other postal service types. Instead, you lot edit them via the Customizer or the Menus screen.
WordPress Post Types: Custom CSS
If you add custom CSS via the Customizer, your work will exist saved using this custom post type. A new post (of the "custom CSS" post type) will be saved for custom CSS relating to each theme in your site, and WordPress volition only apply the one for the currently agile theme.
WordPress Mail service Types: Changesets
Changesets are a bit similar revisions, merely instead of applying to posts, they use to the Customizer. When you make a modify using the Customizer, it will exist saved as a changeset, in a similar way to a draft.
At present that we've worked through the whole spectrum of WordPress mail types, permit's move on to detect out more almost WordPress custom postal service types.
The Difference Between a Post and a Custom Post Type
Let's recap quickly: a postal service tin be one of two things.
A postal service type is a type of mail (in the broader sense) that a given item of content belongs to. And a "postal service" is a post type, every bit is "folio", "attachment" or whatsoever custom mail service type you register (I know, it's confusing but I'll dig deeper in a minute).
On the other mitt, your custom postal service type isn't a type of "postal service" in the sense of a blog mail service. It's a type of postal service in the sense of all posts (of all postal service types) that are stored in the database.
WordPress Custom Mail service Types: Mutual Uses
So now we know what a custom mail service blazon is. Only when might you lot demand to use one? The answer is whenever you desire to add content to your site that doesn't fit into i of the built-in post types.
Some mutual examples of custom mail types are:
- Products for an ecommerce site.
- Portfolio items or projects for a portfolio site.
- Maps for a mapping site.
- Events for a bookings site.
These are some of the most common use cases, just they're by no means the only ones. My advice when deciding whether to use a custom post type for whatever new kind of content is to ask yourself this question:
Do I want to display my new content in the main blog page or as a static folio, or do I want to exist able to show information technology on a carve up archive folio?
In some cases, using a category to divide out your new content might exist enough: mayhap you're running a blog and desire to include case studies that you can display on their own page (using a "Case Written report" category that you create) and also show in the master blog. Just if you lot desire to continue your new content separate from your blog posts, then information technology makes sense to create a custom post blazon for it.
How Post Types are Stored past WordPress
Posts of a custom post type are stored in the aforementioned way every bit standard posts (and pages etc.) are stored. Let's take a look at this in more than detail.
Your WordPress site has a number of database tables to store content and settings. The minimum number of tables is 12, but your site may take more if it's running Multisite or if you have a plugin installed that adds more tables.

In the screenshot above, you can meet that there are ii tables which look as if they might have something to practise with posts: wp_posts and wp_postmeta.
The wp_posts table stores all of the content of your posts, of all post types. And so it doesn't matter if we're talking about a weblog post, a page, a revision, an zipper, or a custom post blazon: they'll all be stored in this wp_posts table.
WordPress knows what post type each postal service is considering it will have a value in the post_type field in the wp_posts table. That value will correspond to the proper name of the mail service type. So when you add a new blog post, WordPress will add together a post to the wp_posts table, with the post_type of "mail service". And if you register a custom mail type called "product", for example, every new production yous create will generate a line in the wp_posts table with "product" as the value in the post_type field.
The wp_postmeta table is for storing metadata about your posts. It has four fields:
- meta_id: the id of this particular in the wp_postmeta tabular array.
- post_id: the post that this item of metadata corresponds to. A postal service tin have multiple lines in the wp_postmeta tabular array.
- meta_key: the central for this detail blazon of metadata. For example, for a static page, one potential primal might be page_template, which would annotation which page template is existence used.
- meta_value: the value for the field. If a page (to employ this instance again) is using the default page template, the meta_value hither would exist 'default'.
And then the kinds of metadata stored for a given post will be different depending on what kind of postal service type it is.
You don't need to worry most which information is stored in wp_posts and which is stored in wp_postmeta: just it'due south useful to understand that all post types are stored in the aforementioned place, as that ways WordPress can piece of work with them all in much the same way.
Where Are Custom Post Types Stored in WordPress?
Your WordPress site has a number of database tables to store content and settings. For case, if yous register a custom post type called "instance report", every new case study you create volition generate a line in the wp_posts tabular array with "production" as the value in the post_type field.
WordPress knows what post type each post is considering it will have a value in the post_type field in the wp_posts table.
How Custom Post Types Interact with Custom Taxonomies and Custom Fields
Earlier we move on to looking at how you would register a custom post type in WordPress, let'due south identify how a custom postal service blazon volition collaborate with other custom content types, namely custom taxonomies, and custom fields.
Custom Taxonomies
Taxonomies in WordPress are used to categorize posts of any post blazon. For standard posts, the ii taxonomies used are categories and tags.
When you register your custom postal service type, you lot tin choose to assign any existing taxonomy or taxonomies to it. You can add the "category" taxonomy to it when you register the taxonomy. I'll prove you lot how to exercise this presently when I demonstrate the technique for creating a custom post type.
Alternatively, you can create completely new taxonomies for your custom post type, which is as well a common approach.
So, for example, if you're creating a "product" post type for an ecommerce site, you lot might create a "section" taxonomy to sort your products into departments in your store.
If y'all're creating an "event" post blazon, you might create a taxonomy of "effect type", which could specify whether this is a concert, a poetry reading, or a comedy nighttime.
The taxonomies you create are upwardly to yous and volition depend on the way you desire to sort and display your posts from your custom postal service type.
Custom Fields
Another custom content type you have in WordPress is custom fields, also known as postal service metadata. Custom fields are additional metadata you can add to any post as long as the mail type supports them. When yous register a custom post type, you can include custom field back up with this line:
supports => array( 'custom-fields' );
This is passed as an array so that y'all tin can add support for multiple options.
So if you want to add metadata to your custom post blazon, such as sizes or colors in a clothing shop with the "production" post type, you'd use a custom field to practise this.
Custom fields are dissimilar from custom taxonomies because you lot wouldn't use them to output an archive page.
Here's an example for a vesture shop. You would have an archive folio for each case of a "section" taxonomy, e.k. "Women'due south", "Men's" etc. Imagine you lot also have a custom field called "Size". Y'all wouldn't create an archive page for each size, as it's not something your customers would expect to see.
Follow this rule to assist you determine whether y'all need to use a custom taxonomy or a custom field to add together more than data to your mail service: volition you lot need to display it in an archive page?
I'll bear witness you how to output archive pages for your custom mail service type and custom taxonomies later.
How to Add a Custom Post Type with a Plugin
So you know what custom post types are and y'all know you need 1 for your site: how do you add it?
There are two ways: by using a plugin, and by coding it manually. Let's start with the plugin route.
There are 2 types of plugins y'all can use to register a custom post type: the first will annals a custom mail service blazon in order to add functionality that comes with the plugin, and the second volition provide yous with an interface y'all tin apply to create your own mail type.
The start case includes a variety of plugins including ecommerce plugins, result plugins, and more than. Let'south offset with 1 of the well-nigh pop WordPress plugins, WooCommerce.
How to Employ WooCommerce to Annals Custom Post Types
WooCommerce is an example of a plugin that registers a custom post blazon in social club to work. In this case, information technology'due south the "production" post blazon.

WooCommerce also registers some custom taxonomies and custom fields for you to organize your shop, including production categories and product tags. These are different from the categories and tags you'd use for your web log posts.
How to Use the Events Calendar Plugin to Register Custom Postal service Types
The Events Agenda plugin is another plugin that uses a custom post blazon. In this case, it'south the "effect" post type.

The plugin adds a taxonomy which is unique to events: "event category". It applies normal tags to events as well, and so you tin apply the aforementioned tags yous use for your blog posts.
Subscribe Now
How to Utilize WP Google Maps to Annals Custom Post Types
Simply similar WooCommerce and The Events Calendar, WP Google Maps is a WordPress map plugin that registers a custom post type for your maps.

The "map" post blazon works differently from the product or upshot mail service type in the previous plugin considering y'all wouldn't display an archive folio of all your maps: instead, the plugin gives you a shortcode for each map you create, that yous embed into a mail service or page in your site. But although you lot tin can't view maps in the same way you would some other mail types, it'southward still a post type.
How to Employ the Custom Post Blazon UI Plugin
If you desire to register your own custom post type instead of ane that's function of the wider functionality provided by a plugin such every bit WooCommerce, you can use a plugin that provides you with an interface designed to make it easy to register a custom post blazon.
One such plugin is the Custom Post Type UI plugin.

This plugin lets yous register your ain custom postal service types using the admin screens, without having to write whatever code.
It gives y'all a fix of screens that let you add all of the elements of registering a post type that you would add in when using the register_post_type()
function. To add together a new post blazon with the plugin, go to CPT IU > Add/Edit Post Types.

From here, you lot can add together a new post type or edit any existing ones you lot've registered.
You can edit the settings for the post blazon or you can exit them at the default settings. You tin find full documentation on all of the settings and options for a post type in the WordPress Codex.

You can besides utilize the plugin to register a custom taxonomy and to assign that to your new mail service type or to any existing post type. And when yous apply the plugin to register a postal service type, you tin can assign any existing taxonomies to information technology as you lot do and so.
How to Use the Pods Plugin to Register Custom Postal service Types
The Pods plugin is another plugin that gives you an interface designed to let you annals a custom post type without writing code.
Pods as well lets you extend your existing post types. So yous can add actress fields to an existing postal service type or taxonomy, and edit their settings.

The Pods plugin uses a post blazon ('pod') to store all of your customizations, and also lets you lot register your own post types a bit like the Custom Post Type UI plugin, but with an interface that's designed to walk you through the process. This means that the plugin can make the process easier, only information technology adds a lot more than code to your site (and information to your database) than if you coded the post type yourself.
Alternatively, if yous'd rather not install a plugin to manage the procedure of registering your mail service type, you can code it yourself.
How to Annals Your Ain Custom Postal service Type in WordPress
If you're comfortable writing lawmaking, you could have advantage of the register_post_type()
office to annals your custom post blazon. This is the well-nigh efficient way to practice it.
Best practices tell us to put code for a custom mail blazon in a plugin, rather than in your theme. This is because if you should change your theme in the time to come, you won't desire to lose the post type and all the posts yous've created with that post type. Information technology also means that if y'all update your theme in the hereafter, y'all won't lose your post type.
Permit's piece of work through the steps to register your own custom postal service type in WordPress.
Creating Your Plugin
The kickoff pace is to create your plugin. In the wp-content/plugins binder of your development or staging site (not your alive site yet), add a binder for your plugin. Inside that binder, add a PHP file. I'one thousand calling mine kinsta-annals-posttype.php.
Tip: I always like to create a plugin inside a binder instead of but adding a plugin file to the wp-content/plugins folder. That way, if I need to add together more files to my plugin, such every bit include files, scripts or styles, I already have a folder set to hold them.
Now in your new php file, add together the opening commented out text for your plugin:
<?php /* Plugin Name: Register Custom Postal service Types Plugin URI: http://rachelmccollin.com Clarification: Plugin to register the volume postal service type Version: ane.0 Author: Rachel McCollin Writer URI:http://rachelmccollin.com Textdomain: kinsta License: GPLv2 */
This tells WordPress (and the user) some key information about the plugin:
- What information technology's called
- Where you can find more information
- What it does
- The version number
- Who developed it, and where you can find out more about them
- The text domain for internationalization
- The license, which should ever be GPL.
Then your plugin is now gear up and if you desire, you can actuate it in the admin screens. Information technology won't do anything yet if you do.
Setting up the Function for Your Mail service Type
Now let's get-go creating the function to annals your post type. In my example, I'm going to create a mail type called "book", as this is for an imaginary book reviews site. What yous employ will obviously be dissimilar and depend on what y'all're using your custom post type for.
Beneath the commented out text, add together this:
function kinsta_register_post_type() { } add_action( 'init', 'kinsta_register_post_type' );
This function will incorporate all of the lawmaking for your custom postal service type. You might desire to alter its name to add a prefix of your own instead of kinsta_. It's skilful practice to use a prefix on all of your functions so that y'all don't clash with the name of any function provided by your theme or the other plugins you're running.
The rest of the code volition be added inside the braces of that function.
Defining the Labels for Your Custom Post Type
Now it'southward fourth dimension to define the labels for your custom post type, Inside those curly braces, add together this:
$labels = assortment( 'name' => __( 'Books', 'kinsta' ), 'singular_name' => __( 'Book', 'kinsta' ), 'add_new' => __( 'New Book', 'kinsta' ), 'add_new_item' => __( 'Add New Book', 'kinsta' ), 'edit_item' => __( 'Edit Book', 'kinsta' ), 'new_item' => __( 'New Volume', 'kinsta' ), 'view_item' => __( 'View Books', 'kinsta' ), 'search_items' => __( 'Search Books', 'kinsta' ), 'not_found' => __( 'No Books Found', 'kinsta' ), 'not_found_in_trash' => __( 'No Books found in Trash', 'kinsta' ), );
You'll need to change yours if your custom mail service type isn't 'volume'. There are more than labels you can use, but I find that the ones in a higher place tend to be sufficient for my needs.
Note that I'1000 using internationalization in my labels then they will exist translated to the local language for users.
Defining the Arguments for Your Custom Post Blazon
The side by side step is to define the arguments, 1 of which volition be that array of labels we already added.
Below the labels and still inside those braces, add this:
$args = array( 'labels' => $labels, 'has_archive' => true, 'public' => true, 'hierarchical' => imitation, 'supports' => array( 'championship', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'folio-attributes' ), 'taxonomies' => 'category', 'rewrite' => array( 'slug' => 'book' ), 'show_in_rest' => true );
Let's take a look at what all of these do.
- The labels statement is the array of labels we already divers.
-
'has_archive' => true
enables a postal service type archive for the custom mail service blazon. This defaults to false so I like to override it and give myself the option of using a post blazon archive (which I'll show you how to employ shortly). -
'public' => true
enables the post type to be included in search results and in custom queries. Over again, the default is false and this is something I like to override. - The 'hierarchical' value will depend on how you lot want to utilize your custom post blazon. If you set this to true, and so the post blazon will comport similar pages, with a hierarchy possible and parent and child posts of whatever mail service of your post type. If you set it to false, it'll behave like posts, without a hierarchy.
- The 'supports' array defines a number of features of post types that you can have this post blazon support. I like to ensure that features such equally featured images and custom fields are turned on.
- The 'taxonomies' statement defines the existing taxonomies that apply to this post type. Hither I'g using the 'category' taxonomy. If you want to use a custom taxonomy instead and oasis't registered it yet, simply skip this line and and then register the taxonomy to the post type. If you've already registered a custom taxonomy, you tin add information technology to the post using this line.
- I'grand using the 'rewrite' argument because I'thousand going to give the taxonomy a proper noun that's unlike from what I want to use for its slug. I'll explain this in more than item shortly.
-
'show_in_rest' => true
ensures that the post blazon is available to the REST API and the Gutenberg interface. Information technology defaults to faux which makes no sense to me – I want all my post types to use the same editing interface!
And then those are all the arguments set. Just we haven't actually registered the post blazon yet. Time to prepare that.
Adding the register_post_type() Office
The concluding step is to pull all of this together into the register_post_type()
function.
Below your arguments, and still inside the braces, add this:
register_post_type( 'kinsta_book', $args );
This registers the 'kinsta_book' post type, with the arguments we've already defined.
At present you might find it easier to sympathise why I used the 'rewrite' statement before. I like to add together a prefix to the names of my post types, so I can be sure they won't clash with any post types added by any third party plugins, only I don't want the prefix to be made public.
By default, when WordPress displays an example of your postal service type, it will use the postal service type's name in the URL. And then my book chosen 'My Wonderful Book' would have a url of mysite.com/kinsta_book/my-wonderful-book. I don't want that, so I use that 'rewrite' statement to change the URL to mysite.com/book/my-wonderful-book. Looks a lot improve, huh?
Now save your file and activate your plugin in the WordPress admin. Y'all'll detect that a new mail type has appeared in the admin card.

The post type is now registered and ready for you to use on your site. Have some time to add some posts to it (posts of your custom post blazon remember, not blog posts – WordPress can get confusing sometimes!) and and then nosotros'll wait at how you can display your posts from your custom post blazon on the front stop of your site.
How to Display WordPress Custom Post Types in Your Site
Most custom post types you add to your site will work like posts, which means they're designed to exist displayed in archive pages. Perchance you're using a custom taxonomy to brandish them, or maybe you lot've added the "category" taxonomy like I have.
Alternatively, if y'all've used a plugin like WooCommerce that adds custom post types in order to add together specific functionality to your site, then that plugin might add together some specific pages (like the "Shop2 folio) designed to output your custom post blazon.
The four options yous have for displaying custom post types are:
- Displaying the individual post (i.e. the book, in my case)
- Displaying the full mail service type annal, with all of the books listed.
- Displaying a custom taxonomy archive, using a taxonomy you've registered for your custom mail type.
- Integrating posts from the custom post type (e.g. books) into the annal for an existing taxonomy such equally 'category', or into the master blog page.
Let's have a await at each of these in plow.
Alert! If at any point in this procedure y'all tin can't access the archives or private posts for your custom post type, its because WordPress hasn't yet written the permalinks for them. To fix this, go to Settings > Permalinksand but click the Relieve Changesbutton. This will tell WordPress to check for any new post types and create the URLs for them.
Displaying the Post Type Archive
The first option you have is to create an archive folio of all the posts in your custom mail type annal.
If you defined 'has_archive' as truthful when you lot were registering the post type, WordPress will automatically generate an annal page for your postal service type. You tin add together this to your navigation menu using the Customizer.
Adding Your Post Type Annal to the Menu
Open the Customizer and select the Menusoption. Select your primary menu and click the Add itemspush to add together actress items to your carte du jour.

Select your post type from the options that appear and click not he downwards arrow to the right of its name. This will display al listing that includes each of the posts you've added, plus an option which in my instance is called All Books. Click on that and information technology will be added to your menu.
If you then click on that particular in the menu, you tin edit the characterization. I prefer not to call mine "All Books", just just "Books" instead.

Annotation that you can but do this via the Customizer – it isn't possible in the Menus screen. And then make certain y'all use the Customizer to add your custom post blazon archive to your menu.
Customizing the Postal service Type Archive
WordPress will utilise the template hierarchy to identify which template file in your theme to use to display the custom mail type annal.

If your theme has an archive.php file, it will use that, and if information technology doesn't, it will utilise index.php.
If you want to edit the way that the custom post type archive is output, and so y'all can create a template file for your custom post type archive.
For a specific custom post type, you demand to create a template file called archive-$posttype.php, where $posttype is the proper name of your post type. Then for my books mail type, I'd create a file called annal-kinsta_book.php.
The easiest way to create this file is by making a duplicate of the archive.php file in your theme. Rename it and edit it and then it displays your post type annal the way you want to.
Displaying Unmarried Posts
Single posts created using a custom post type will also be shown using the start relevant template file that's plant in the template bureaucracy.
Y'all can get a bit further with single posts than y'all tin with athenaeum: non only tin can you lot create a template file for the mail service type (single-$posttype.php), simply you lot can also create a file for a specific mail of that mail blazon using the slug for that post (single-$postype-slug.php).
So if I added Great Expectationsto my book reviews site, I could create a file for all book reviews called single-kinsta_book.php, or I could create a target file for that book called single-kinsta_book-keen-expectations.php. If I didn't create either of those files, WordPress would default to using unmarried.php or (if that didn't be) singular.php or index.php.
Adding Custom Post Types to the Main Blog Page
By default, your main blog page volition only include the 'postal service' mail blazon. But what if y'all also wanted to include your custom post blazon on that page, mixed up with the blog posts?
You can do this by using the pre_get_posts claw in WordPress.
In your plugin where you registered the post type, add this:
<?php office kinsta_books_on_blog_page() { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'post_type', assortment( 'postal service', 'kinsta_book' ); } } add_action( 'pre_get_posts', 'kinsta_books_on_blog_page' ); ?>
This checks that we're on the 'abode' page (which is the blog page, even if that isn't the forepart page of your site) and that the primary query is running (considering you don't want to do this in a widget, for example). If so, it adds both posts and books to the query.
Notation that you have to include the 'mail' postal service type in the array likewise as the new post type.
Summary
WordPress custom postal service types are the feature that elevates information technology from a simple blogging platform to a true content direction organization. They let yous create circuitous, bespoke sites that can deed as stores, reference hubs, media sites, or anything you're in need of.
You can add custom post types to your WordPress site in one of three ways. Yous can use a plugin such as WooCommerce that registers a custom post type related to the functionality of the plugin. You can employ a plugin like CPT UI or Pods to add your own custom postal service types. Or you lot tin can write your own plugin and utilize the register_post_type()
office to register the post type using code. Whichever method you use, you'll be able to go much more from your WordPress site.
Salvage time, costs and maximize site operation with:
- Instant help from WordPress hosting experts, 24/vii.
- Cloudflare Enterprise integration.
- Global audition attain with 32 data centers worldwide.
- Optimization with our built-in Application Performance Monitoring.
All of that and much more, in one plan with no long-term contracts, assisted migrations, and a thirty-24-hour interval-money-back-guarantee. Check out our plans or talk to sales to discover the plan that'southward correct for you.
How To Register A Custom Post Type In Wordpress In A Plugin,
Source: https://kinsta.com/blog/wordpress-custom-post-types/
Posted by: cephaswhersely1982.blogspot.com
0 Response to "How To Register A Custom Post Type In Wordpress In A Plugin"
Post a Comment